iphone: get User Defined variable in Target's setting by code?

后端 未结 2 1625
萌比男神i
萌比男神i 2021-02-01 02:57

My project have multi-targets. Each target has its own Class file for setting stuff. I want to store that Class name in a target setting (Info.pl

2条回答
  •  死守一世寂寞
    2021-02-01 03:39

    As the Info.plist file is preprocessed too, you can use this approach:

    Define a User defined setting in your build settings, for Example CLASS_NAME. And a key to your Info.plist-file. Name the key CLASS_NAME and set the value to ${CLASS_NAME}.

    You can then access this setting by:

    NSString* className = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CLASS_NAME"];
    

提交回复
热议问题