Howto set DEBUG & NDEBUG macros in Xcode Profiling and Archiving Builds?

4.3k views Asked by At

In Xcode (currently version 4.3.2), I have the DEBUG and NDEBUG macro definitions set for Debug and Release Builds, so I can selectively include debugging code with the ObjC preprocessor.

Problem: When I select Product --> Build For --> Archiving, neither DEBUG nor NDEBUG are defined. I have a similar problem with Product --> Build For --> Profiling.

Question: How do I properly set DEBUG and NDEBUG in xcode for the Archiving and Profiling builds, such that my conditional code inclusion (preprocessor) macros don't break?

My current workaround for Archiving a build before sending to the AppStore is to just temporarily delete the DEBUG code; but this is not a good practice, even though I'm protected by git's source-version-control-system.

2

There are 2 answers

0
CReaTuS On

Try add your definitions into

"Preprocessor Macros Not Used in Precompiled Headers"

instead

"Preprocessor Macros"
1
mattwyskiel On

Check the build settings to make sure that the macro is defined in BOTH Debug and Release mode.

For example:
- For Debug mode: NDEBUG=0 and DEBUG=1
- For Release mode: NDEBUG=1 and DEBUG=0