This tutorial shows you how to selectively run your debug or production code using flags. Sometimes you may find it necessary to only run some code in Debug mode and other code in Release mode. Swift Open your Project Build Settings and search for “Swift Compiler – Custom Flags” … “Other Swift Flags”. Add -DDEBUG to the Debug section Add -DRELEASE to the Release section In Swift you can use the following code: