Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Preprocessor Definition via a Xcode Scheme

Tags:

xcode

ios

gcc

I currently have a number of special "flavors" of an iPhone application that I need to build. Ideally, I would like to have a scheme for each "flavor" and each scheme would define (or set) one or more preprocessor definitions that I can use to branch on in my code and possibly even preprocess my info.plist file. This can obviously be done with multiple targets, but since I could have many different "flavors" of the app, it would be great to do it with schemes to keep the target count down. My current thought is to add these preprocessor definitions during a pre-action script, but I can not for the life of me find any way to update GCC_PREPROCESSOR_DEFINITIONS. Since it is an environment variable, shouldn't I have access to append onto GCC_PREPROCESSOR_DEFINITIONS?

like image 648
Christopher A Avatar asked Nov 29 '11 23:11

Christopher A


1 Answers

Worse case scenario you can do a pre-build script for the scheme. You'll have to include the script for every scheme though:

I would prefer to attach it to a Configuration:

Then you can easily add preprocessor macros for the various configurations, like I have here for Debug:

The <ProjectName>_Prefix.pch file is a great place to put macros that effect the whole program, like I have here:

In my example we're effectively turning off console output when not in debug mode, providing a little speed boost.

like image 165
Dustin Avatar answered Nov 22 '22 00:11

Dustin