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.
- Open your Project Build Settings and search for “Swift Compiler – Custom Flags” … “Other Swift Flags”.
-DDEBUGto the Debug section
-DRELEASEto the Release section
In Swift you can use the following code:
#if RELEASE // release only code #else // debug only code #endif
#if DEBUG // debug only code #else // release only code #endif
- In Objective-C, the DEBUG flag is already defined as a preprocessor macro. However, you will need to add the RELEASE flag by going to your Project Build Settings and searching for
RELEASE=1to the Release section
In Objective-C you can ue the following code:
#ifdef RELEASE // release only code #else // debug only code #endif
#ifdef DEBUG // debug only code #else // release only code #endif
Get insights into your Apple Search Ads performance and optimize your bids and keywords for maximum revenue with Kitemetrics by Kitefaster.
Tested with the following versions:
- Xcode 7.2
- iOS 9.2.1
- tvOS 9.1
- Swift 2.1.1
Keyword level attribution for Apple Search Ads. Optimize your bids and increase your revenue. Sign up for free at kitemetrics.com.