Xcode 调试方案

dar*_*234 4 xcode swift

我设置了调试方案,并将预处理器宏上的 DEBUG 标志设置为 1,但是当我设置如下所示的内容时:

func print(_ object: Any) {
#if DEBUG
    Swift.print(object)
#endif
Run Code Online (Sandbox Code Playgroud)

}

即使在调试模式下也不会打印。我该如何纠正这种行为?

Cod*_*ent 6

转到Build Settings并添加-D DEBUGOther Swift Flags

其他 Swift 标志

然后这将正常工作:

#if DEBUG
    print("This is DEBUG")
#else
    print("This is not DEBUG")
#endif
Run Code Online (Sandbox Code Playgroud)