Thursday, 12 February 2009

Identifying the Current Xcode Configuration

The easiest way to identify the current configuration in code is by creating a preprocessor macro under your Xcode project build settings.

Step by step:
  1. Project menu -> Edit Project Settings -> Build tab
  2. Select All Configurations
  3. Scroll down to GCC 4.0 - Preprocessing
  4. Add the following to Preprocessor Macros Not Used in Precompiled Headers:

Assuming you have Debug, Adhoc and Release configurations, this will generate preprocessor macros for each configuration. ie
In your code you can now use something like:

NSLog(@"Debug message");

#if defined (CONFIGURATION_Debug) || defined (CONFIGURATION_Adhoc)
NSLog( @"Warning message");

1 comment:

  1. Thanks, this worked great. Now I can easily have my application automatically back up the database every launch when I give out buggy versions to beta testers.

    In case anyone is having trouble finding the build setting, your project must have the "Active SDK" set to whatever option says "(Project Setting)". More info about that here: