Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning on 'DEBUG' macro value

Tags:

iphone

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?

like image 306
Robin Jamieson Avatar asked Jul 05 '26 04:07

Robin Jamieson


1 Answers

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.

like image 151
pgb Avatar answered Jul 07 '26 21:07

pgb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!