Reputation: 87
I am trying to change an image for the two different versions of my app. Here is the code that i have tried so far.
- (void)viewDidLoad
{
[super viewDidLoad];
#ifdef LITE_VERSION
setImage:[UIImage imageNamed: @"30 Tap Game Logo Lite.png"];
#endif
}
Upvotes: 0
Views: 219
Reputation: 7102
You will need to configure your targets' Preprocessor Macros. If you select your target in Xcode and select Build Settings, then search for "preprocessor macros" you'll find the setting you need.
In your light version target (and only in that target) you'll need to add a macro like "LITE_VERSION=1". Then when you build the light version target LITE_VERSION
will be defined.
You might also consider using #if LITE_VERSION
instead of #ifdef LITE_VERSION
just in case you ever want to explicitly turn off LITE_VERSION
with #define LITE_VERSION=0
.
If you're not sure whether or not your preprocessor macros were set up correctly, you can do something like this:
#ifdef LITE_VERSION
#error Light version is defined.
#else
#error Light version is not defined!
#endif
That will cause the preprocessor to generate an error clearly showing whether or not your macro is defined. (It will also stop the build process, so you can't leave that snippet in your code, but it might help you debug your target configurations.)
Upvotes: 3