【Swift4.2】マクロを使ってDebug、Staging、Releaseの3つに処理を振り分ける方法【Xcode10】
マクロを使って処理を振り分けたい時の設定方法です。
全て「プロジェクト > TARGET > Build Setting」の設定を変更します。
ちなみに、設定前にTargetを増やす方法かSchemを増やす方法をして置く必要があります。
またObjective-CとSwiftで設定が異なります。
Swfitではとりあえす、以下3つの設定をしておくといいでしょう。
1. Preprocess Macrosの設定

DebugにDEBUG=1
StagingにSTAGING=1
2. Other Swift Flagsの設定

Debugに-DDEBUG
Stagingに-DSTAGING
3. Active Compilation Conditionsの設定

DebugにDEBUG
StagingにSTAGING
テストコード
#if DEVELOP
print("開発です")
#elif STAGING
print("検証です")
#else
print("本番です")
#endif