views:

329

answers:

1

Hi

I have found a set of great macros here Objective C Macros

I put the:

#if DEBUG==1
#define .... macros

in my header file.

Now I simply can't figure out where to set DEBUG=1 or DEBUG=0 in Xcode so that it will define the macro when debugging and not when releasing.

Hope someone can help me find the missing drop down menu:) Thanks

+1  A: 

EDIT:

Ok apparently, when working on an iPhone application, you have to:

  • select iPhone device as the active sdk
  • then edit project or target settings and in "Other C Flags" you type "-DDEBUG=1"

Edit your project or target settings, select your Debug configuration then look for the "Preprocessor Macros" settings and type DEBUG=1

However, I would rather define NDEBUG in the Release configuration then write

#ifndef NDEBUG // if we are in debug mode
#define bla bla bla
#endif

Note: you need to have a target that compiles Objective-C source files to a library or application properly set up; otherwise the settings don't appear in the UI.

Gregory Pakosz
Hi thanks guys.I now went "Project" -> "Edit Project Settings" - "Build tab" and under the header "Packaging" there was a "info.plist Preprocessor Definitions". I takes space separated values says the manual. I tried putting "DEBUG=1" here and then restart Xcode. But it does not work?All the NSLog macros I try to use yields no output, but no warnings or errors either. It seems as if DEBUG=0 still.
RickiG
Hi GregoryIm compiling and debugging for the iPhone Simulator. Does this qualify?If I omit the if... part it works just fine. Just seems I can't figure out where to define **DEBUG**.Thanks again for your help
RickiG
no it should be in the "GCC 4.0 Preprocessing" (or alike) section not "Packaging"
Gregory Pakosz
I just tried with a dummy iPhone app, see my edited answer
Gregory Pakosz
Thank you Gregory!I work like a charm in both Simulator and Device. Not the most obvious path to get there though:) Thanks again for figuring it out.
RickiG
Exactly, that's just awful, I was so surprised at first when I tried :) Have fun
Gregory Pakosz