Xcode 中未设置 DEBUG 宏,而 运行 项目处于调试模式

DEBUG macro is not set in Xcode while running the project in debug mode

我创建了一个新的 react-native 项目,其中包含一个 Android 项目和一个 iOS 项目。我正在使用 Swift,所以我将 AppDelegate.mAppDelegate.h 文件替换为 AppDelegate.swift。我在 swift 文件中像这样使用 DEBUG 宏,但即使在调试模式下它也始终设置为 false,因此我无法使用它。

    #if DEBUG
      let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
    #else
      let jsCodeLocation = Bundle.main.url(forResource: "main", withExtension: "jsbundle")
    #endif

我在 Xcode 上的 Build Settings 中搜索 debug,我发现下面的设置似乎正确。

我如何确保在 运行 调试模式下设置 DEBUG 宏,而不设置其他方式。谢谢。

  1. 打开项目构建设置并搜索 Swift Compiler – Custom Flags
  2. 然后转到 Other Swift Flags 并将 -DDEBUG 添加到调试部分

让我知道这是否有效,我在 lib 很久以前就用过这种方法