简体   繁体   English

预处理程序指令,用于分隔xcode中的目标

[英]Preprocessor Directives to separate targets in xcode

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? 有人可以告诉我该怎么做吗?

Thank you, 谢谢,

~Sonic555gr 〜音速555gr

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中使用它,则必须在此处声明它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM