在 xcode 中分离目标的预处理器指令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16341557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Preprocessor Directives to separate targets in xcode
提问by L_Sonic
I have 2 targets on my project one production and one stage with different configurations. I want in the code to be able to say
我的项目有 2 个目标,一个是生产,一个是具有不同配置的阶段。我希望在代码中能够说
#if target == production
NSLog(@"production");
#elif target == stage
NSLog(@"stage");
#endif
Can someone please tell me how can I do that?
有人可以告诉我我该怎么做?
Thank you,
谢谢,
~Sonic555gr
~Sonic555gr
回答by xapslock
You can define some Preprocessor Macros for each Target, like this...
您可以为每个目标定义一些预处理器宏,如下所示...
And then you can do something like this:
然后你可以做这样的事情:
#ifdef PRODUCTION
//some Code
#elif STAGE
//some other Code
#else
//more Code^^
#endif
But be carefull if you need it in Debug- and/or in Release-Build, you have to declare it there.
但是要小心,如果您在 Debug- 和/或 Release-Build 中需要它,您必须在那里声明它。