开发者

Xcode Objective-c Compile Time Conditional

开发者 https://www.devze.com 2023-03-29 14:42 出处:网络
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 li

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消