I need to configure my environments in a way that points the app to dev server when testing internally on TestFlight, and points to prod server when pushed to actual App store. I have Debug & Release variables setup. When app is archived, build configuration is set to Release. I'd like to point to dev server up until its pushed to App Store through iTunes-Connect. Or is it normal to just change build config to Debug when pushing to TestFlight for testers, and change back to RELEASE when pushing to app store? Thanks.
1 Answers
You can achieve this using schemes
1) Create a new configuration in Project -> Info -> Configurations
, by duplicating the Release
2) Set the appropriate Provisioning profile(adhoc or distribution in your case) and Code Signing Identity for the new configuration in Build Settings
3) Create a new scheme for your internal release,
4) Edit the new scheme's Archieve to your new Configuration
5) So far what we have handled your use case of pointing to dev server in case of internal testing/release. for that we have to create a new compiler flag(Swift)/Preprocessor Macro(Objective-C).
Objective-c
Go to Build Settings -> Preprocessor Macros
Add a new macro "DEV_RELEASE=1" under the new configuration
Note: Also for set the RELEASE=1 flag as well if its not already set under release configuration.
Swift Go to Build Settings -> Swift Compiler - Custom Flags under Active Compilation Conditions, Add the Flags RELEASE and DEV_RELEASE to the appropriate Release and Dev(Release) configurations.
6) Now you will have access to these Macro/CompilerFlags in your code
#ifdef DEBUG
NSString* serverURL = @"https://dev.com”;
#elif RELEASE
NSString* serverURL = @"https://prod.com”;
#elif DEV_RELEASE
NSString* serverURL = @"https://dev.com”;
#endif
7) When you wanna sent a internal Build(adhoc or Testflight) just switch the Scheme and Archieve

- 698
- 4
- 11