tags:

views:

669

answers:

3

In my code, I want to conditionally perform a few operations with:

#ifdef DEBUG
NSLog(@"I'm in debug mode");
#endif

I've configured Project->Edit Project Settings->Build tab so that 'DEBUG' is listed as a User-Defined setting with a value of 1. Debug is selected in the Configuration dropdown. This still doesn't turn on the directive for the Debug build although I thought that's what it would do.

What else do I need to do during the build stage to allow for this?

A: 

project -> settings -> c/c++ (or code generation?) look for a text box labeled Preprocessor Definitions and just add DEBUG to the end of the comment separated list.

ryansstack
Is this in XCode? Don't see a C/C++/Code Generation menu option.
Robin Jamieson
hahaha. my bad, your question wasn't clear to me.
ryansstack
+2  A: 

You need to set a compiler flag for that.

To do it, Get Info on the target, make sure you have selected the Debug configuration (and not All Configurations), and look for Other C Flags and Other C++ Flags (in Xcode 3.1 these are under GCC 4.2 - Language).

Then add the following as a value: -DDEBUG for both.

This will define the DEBUG for the precompiler to pick it up.

pgb
A: 

The above solutions seem like SDK 3.0 solutions, I'm still living in a 2.2.1 world with XCode 3.1.

This link did the trick for me, complete with pictures!

Mike