我设置了调试方案,并将预处理器宏上的 DEBUG 标志设置为 1,但是当我设置如下所示的内容时:
func print(_ object: Any) {
#if DEBUG
Swift.print(object)
#endif
Run Code Online (Sandbox Code Playgroud)
}
即使在调试模式下也不会打印。我该如何纠正这种行为?
转到Build Settings并添加-D DEBUG到Other Swift Flags。
然后这将正常工作:
#if DEBUG
print("This is DEBUG")
#else
print("This is not DEBUG")
#endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
815 次 |
| 最近记录: |