ios - 如何确定我的 iOS 应用程序正在 DEBUG 模式下运行?

标签 ios objective-c swift compilation

代码:

#if DEBUG
    let iAmInDebugMode = true
#else
    let iAmInDebugMode = false
#endif

项目设置:

enter image description here

方案设置:

enter image description here

结果:

println(iAmInDebugMode) // false

为什么?我做错了什么?

最佳答案

在 swift 中它不会像这样工作,你需要在其他 swift 标志中设置标志 -D DEBUG 然后它会工作。您可以获得有关构建配置标志的更多详细信息 here

enter image description here

关于ios - 如何确定我的 iOS 应用程序正在 DEBUG 模式下运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32025020/

相关文章:

iphone - GCD Dispatch Sources 和 select() 有什么区别?

ios - UICollectionView scrollToItemAtIndexPath : and get fresh cell position

ios - Azure 通知中心 - 如何在同一中心设置多个应用程序

objective-c - ARC 是否跟踪 [NSString UTF8String] 生成的 const char* ?

ios - 无法从文件路径创建 UIImage

iphone - 两个 UIView 之外的最小矩形 - Objective C

ios - 使用 Xcode 提交到 App Store

swift - iOS UILabel textColor 在暗模式下不更新

ios - 使用Swift和iOS保存文件

ios - Segue 没有将数据传递给第二个 VC