How to differentiate multiple targets with Xcode 4.2

拥有回忆 提交于 2019-11-29 14:07:59

问题


I've developed a lite version of an app. Now I want to create a paid version. So I've duplicated the target, changed its name (so change plist and other stuff with that name) and now I have to differentiate in code. I'm using Xcode 4.2 and I see on the web that I have to create a preprocessor flag. My problem is that this flag in Xcode 4.2 is only in the project's build setting and not in the target's build setting.

I will need to be able to do something like this:

#ifdef paid
    ...
#else
    ...
#endif

回答1:


Use preprocessor macros to do this. Go to Target -> Build Setting and choose "All configurations" (this is very important). Next find field "Preprocessor Macros".

In this field, add the flag in ex. PAID_VERSION. Now you can use this flag in code:

#ifdef PAID_VERSION
    NSLog(@"Paid version");
#else
    NSLog(@"Lite version");
#endif


来源:https://stackoverflow.com/questions/8848263/how-to-differentiate-multiple-targets-with-xcode-4-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!