How to differentiate multiple targets with Xcode 4.2
Asked Answered
F

1

11

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
Faxan answered 13/1, 2012 at 9:19 Comment(1)
possible duplicate of XCode 4 - how to build a "lite" versionCorot
V
19

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
Vixen answered 13/1, 2012 at 10:45 Comment(1)
i didn't find preprocessor for target cause i didn't choose all configuration :) THANKS!Faxan

© 2022 - 2024 — McMap. All rights reserved.