Question

When Xcode shows a preprocessor macro of DEBUG=1 in its Build Settings, is this equivalent to typing a preprocessor macro manually, such as #define DEBUG 1 ?

Was it helpful?

Solution

Yes, that corresponds to the "-DDEBUG=1" preprocessor option which is equivalent to a macro definition #define DEBUG 1 that is read before any source file is processed.

OTHER TIPS

Yes, But only in the Debug configuration. If you add #define DEBUG 1 to your code then DEBUG will be defined in both the Release and Debug configurations. Different actions use different build configurations

Action   |  Configuration
--------------------------
Run      |  Debug
Test     |  Debug
Profile  |  Release
Analyze  |  Debug
Archive  |  Release

So by defining DEBUG in the Build Settings you can add code that only runs in your local builds. But not in your Ad Hoc or App store versions.

#ifdef DEBUG
    [self.tapGestureRecognizer addTarget:self action:@selector(segueHiddenDevMenu:)];
#endif

This code adds a developer only menu to "Nuke and Pave the Database", "Add 10000 new records to the Database", Create the Default Image View. Stuff the users should not play with. And hidden functionality that would get your app rejected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top