Sep 10

In this post How To Create Conditional Log Statements in Xcode I described how you could add a DEBUG flag to your Xcode project setting so that you could use statements like #ifdef DEBUG in your code.

If you follow the instructions in the post for a 3.0 project you will get an error:

There’s already another key named “GCC_PREPROCESSOR_DEFINITIONS”. Please enter a different name.

If you scroll through all the build settings you will not find one labeled GCC_PREPROCESSOR_DEFINITIONS. This is because this setting has helpfully been relabeled “Preprocessor Macros” and is now listed under the heading GCC 4.2 – Preprocessing:

PreprocessorMacros

To find out how any of these new “helpful” labels are actually translated to compiler settings, click on the Research Assistant button at bottom left corner of the window (the button that looks like a pair of reading classes on top of a stack of books) and you’ll see this:

Xcode Research Assitant

Note that I’ve only seen this change for projects that I’ve created in Xcode 3.1.3 (which by default only have a SDK 3.0 target). Projects that were created in older versions of Xcode (even if they can target SDK 3.0) still show the GCC_PREPROCESSOR_DEFINITIONS label under the heading User-Defined.

written by Nick \\ tags: ,

One Response to “How To Add DEBUG Flag In A 3.0 Project In Xcode”

  1. Dawn Says:

    In case someone else has the same problem I had…

    I was unable to set DEBUG=1 because the “GCC 4.2 – Warnings” section disappeared when I chose the Debug configuration. Changing the base SDK from Simulator to iPhone Device fixed that and now #ifdef DEBUG works again.

Leave a Reply