2

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.

AnonProgrammer
  • 239
  • 1
  • 11

1 Answers1

5

You can achieve this using schemes

1) Create a new configuration in Project -> Info -> Configurations, by duplicating the Release enter image description here

I named it as Dev(Release) enter image description here

2) Set the appropriate Provisioning profile(adhoc or distribution in your case) and Code Signing Identity for the new configuration in Build Settings enter image description here

3) Create a new scheme for your internal release, enter image description here enter image description here

4) Edit the new scheme's Archieve to your new Configuration enter image description here

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     

enter image description here

  Add a new macro "DEV_RELEASE=1" under the new configuration

enter image description here 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.

enter image description here

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 enter image description here

Gokul G
  • 698
  • 4
  • 11