IPHONE: Environment Variables & #define directives

To use Configuration-defined #defines

Step 1: Right click on the project/target and select Get Info.

Step 2: Under the Build tab, select the Configuration you want to associate the #define with (ie. Debug/Release)

Step 3: Under User-Defined (Setting) all the way at the bottom, find a field that's called

GCC_PREPROCESSOR_DEFINITIONS

Step 4: If a field doesn't already exist, create it by clicking on the Gear on the bottom left & selecting Add User-Defined Setting.

Step 5: For the VALUE, input your #define variable. (ie. TEST_DEFINES)

Step 6: Now in code you can use

#ifdef TEST_DEFINES
... do something
#else
... do something
#endif

No comments: