使用Swift区分两个Xcode目标 [英] Differentiate between two Xcode targets with Swift
本文介绍了使用Swift区分两个Xcode目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Swift区分两个Xcode目标?我们的想法是在Xcode中创建一个具有相同代码库的应用程序的免费和付费版本。
How can I differentiate between two Xcode targets with Swift? The idea is to make a free and a paid version of an app with the same code base in Xcode.
使用目标CI可以使用预处理器宏但是使用Swift则不可用。
With objective C I could use preprocessor macros but with Swift those are unavailable.
推荐答案
从Xcode 8开始,您可以在 Active Compilation Conditions <下的每个目标的Build Settings中设置编译条件/ strong>。
Since Xcode 8 you can set the compilation conditions in the Build Settings for each target under Active Compilation Conditions.
有了这些设置,你可以使用:
With those set you can use:
#if FREE
//do something
#endif
有关详细信息,请参阅 i40west答案和评论。
For more details see the i40west answer and comments.
这篇关于使用Swift区分两个Xcode目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文