InternationalCodingGuru
InternationalCodingGuru

Reputation: 2258

Xcode Objective-c Compile Time Conditional

I'm working on an iOS project in xcode and I'd like to include different codes depending on the build scheme. ie: For anything except the Distribution on an iOS Device scheme, I'd like to include a bunch of debug stuff. But for the Distribution on an iOS Device scheme, I don't want to include the debug stuff.

If I can add some sort of conditional code block it will be very helpful as it will eliminate the chance of me forgetting to change the flag manually.

Thanks!

Upvotes: 2

Views: 2056

Answers (1)

Joe
Joe

Reputation: 57169

By default when you create a new XCode 4 project it will add DEBUG to your GCC_PREPROCESSOR_DEFINITIONS (Preprocessor Macros) under build settings so you can do the following.

#ifdef DEBUG
    //Debug only code here
#endif

If you need more preprocessor definitions add them under GCC_PREPROCESSOR_DEFINITIONS or OTHER_CFLAGS or OTHER_CPLUSPLUSFLAGS [prefix the last 2 with -D] for the correct build configuration.

Upvotes: 9

Related Questions