条件编译 - 检查方案 [英] Conditional Compilation - Check Scheme

查看:168
本文介绍了条件编译 - 检查方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我能够执行简单的编译器检查以查看正在运行的方案之前的Swift项目中,然后有条件地包含代码。例如:

In a Swift project before I've been able to perform a simple compiler check to see which scheme is running, then conditionally include code or not. For example:

#if MyScheme
    Add code here
#endif

但出于某种原因,在我的Objective-C项目中,这似乎不起作用。这应该以同样的方式工作吗?或者Swift编译器是否有一些允许这种行为的改进?

But for some reason, in my Objective-C project, this doesn't seem to be working. Should this work the same way? Or does the Swift compiler have some advancements which allow this kind of behaviour?

推荐答案

使用 #ifdef

//example for debug scheme
#ifdef NDEBUG
   Add code here
#endif

您可以在此处定义预处理器宏

希望这会有所帮助

这篇关于条件编译 - 检查方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆