1). 关于#if DEBUG
, xcode默认支持了Swift preprocessor, 不再需要设置 "Other Swift Flags".
https://stackoverflow.com/questions/38813906/swift-how-to-use-preprocessor-flags-like-if-debug-to-implement-api-keys
Apple included full support for Swift preprocessor flags as of Xcode 8, so it's no longer necessary to set these values in "Other Swift Flags".
The new setting is called "Active Compilation Conditions", which provides top-level support for the Swift equivalent of preprocessor flags. You use it in exactly the same way as you would "Other Swift Flags", except there's no need to prepend the value with a "-D" (so it's just a little cleaner).
2). 如何判断是adhoc appstore testflight
参考: https://gist.github.com/steipete/7668246
3). 判断是模拟器
swift4.2+
#if targetEnvironment(simulator)
return false
#else