Using #ifdef DEBUG with Schemes in iOS

Objective C

Value of DEBUG is predefined in target’s build settings.

DEBUG_DEF

To use different host url for DEBUG and RELEASE mode, apply the if-else logic.

#ifdef DEBUG
#define HOST_URL @"http://xxx-uat/"
#else
#define HOST_URL @"https://xxx/"
#endif

Swift

For Swift, you need to define a DEBUG value in target’s build settings – Custom Flags.

CUSTOM_FLAGS

And apply the if-else logic in Swift.

#if DEBUG
static let hostUrl = "http://xxx-uat/"
#else
static let hostUrl = "https://xxx/"
#endif

You can also create schemes for UAT and Production releases, and setting the build configuration as Debug or Release based on your needs.

If you need to have different bundle identifier for UAT and Production releases, you can create the second target with different build settings and info plist.