预处理程序指令,用于分隔xcode中的目标 [英] Preprocessor Directives to separate targets in xcode
本文介绍了预处理程序指令,用于分隔xcode中的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目中有2个目标,一个产品和一个阶段具有不同的配置. 我希望代码中能够说出
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
#if target == production
NSLog(@"production");
#elif target == stage
NSLog(@"stage");
#endif
有人可以告诉我我该怎么做吗?
Can someone please tell me how can I do that?
谢谢
〜Sonic555gr
~Sonic555gr
推荐答案
您可以为每个目标定义一些预处理器宏,如下所示...
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
但是如果需要在Debug和/或Release-Build中使用它,则必须小心,必须在此处声明它.
But be carefull if you need it in Debug- and/or in Release-Build, you have to declare it there.
这篇关于预处理程序指令,用于分隔xcode中的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文