xcode - 为什么没有设置 Swift 编译器标志?

标签 xcode swift

我希望某些代码仅在发布版本中执行,但当方案配置为使用发布配置时代码不会执行。

我错过了什么?

我的应用委托(delegate)的 didFinishLaunchingWithOptions 方法中有以下内容:

#if RELEASE
    Countly.sharedInstance().startOnCloudWithAppKey(appKey)
    Crittercism.enableWithAppID(appID)
    NSLog("crash logging enabled")
#endif

目标build设置如下所示: screenshot of the Swift Compiler - Custom Flags section in Xcode

并且该方案配置为在我运行应用程序时使用发布配置: Screenshot of release scheme configuration in Xcode

最佳答案

您需要在“Swift 编译器 - 自定义标志”部分的“其他 Swift 标志”行中明确设置预处理器标志。

请检查-

In absence of preprocessor macros, is there a way to define practical scheme specific flags at project level in Xcode project

关于xcode - 为什么没有设置 Swift 编译器标志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30791661/

相关文章:

xcode - .gdbinit 配置文件与 Xcode 调试冲突

ios - 应用程序在启动时崩溃

swift - 巨大的Dictionary对象时编译错误。打破表达

iphone - 什么是记录用户异常的在线服务?

ios - 在 UISwitch 中放置文本 swift 4

swift - 'CGRectGetMaxX'已由属性 'CGRect.maxX'替换为swift错误

ios - 如何从特定的 UICollectionViewCell 中删除 firebase 子节点 - Swift

iphone - UITableView 内存泄漏与 imageWithContentsOfFile

swift - 运行 HKStatisticsCollectionQuery 示例代码时出现 "ambiguous use of ' 组件错误

ios - 为什么当我尝试附加数组时应用程序崩溃?