Best way to Manage Development, Testing, and Production builds with different settings and name

The difference between a debug and a release build is that one is archived off and exported but the other is run locally via Xcode in the debugger. You might find that you want to sometimes run the production or staging build in the debugger too but by splitting stuff out by #ifdef DEBUG, you are probably going to run into issues.

This is a simplified version of what I do:

Create Individual Configurations

In the project (not target) settings, create (duplicate from the originals) the following configurations:

  • Debug_Dev
  • Debug_Staging
  • Debug_Prod
  • Release_Dev
  • Release_Staging
  • Release_Prod

Note that if you use Cocoapods then you will need to set the configurations back to none, delete the contents of the Pods folder in your project (Not the Pods project) and re-run pod install.

Create a scheme for each environment

Instead of just having a MyApp scheme, create the following (duplicate the original):

  • MyApp_Dev
  • MyApp_Staging
  • MyApp_Prod

In each scheme, use the associated Debug_* and Release_* configurations where appropriate.

Add a preprocessor macro to identify environments

Add an additional preprocessor macro to identify what environment you are building against.

In the project build settings, click the + and add a user defined build setting and call it something like MYAPP_ENVIRONMENT. Then, for each different group of environments, add a different preprocessor macro to each one. i.e ENV_DEV=1, ENV_STAGING=1 and ENV_PROD=1.

Then, in the c preprocessor macros (again on a project level and not the target level) add this new MYAPP_ENVIRONMENT setting using $(MYAPP_ENVIRONMENT).

This way, you can then determine what environment you are building against like so:

#ifdef ENV_DEV
    NSString * const MyAppAPIBaseURL = @"https://api-dev.myapp.com/";
#elif ENV_SAGING
    NSString * const MyAppAPIBaseURL = @"https://api-staging.myapp.com/";
#elif ENV_PROD
    NSString * const MyAppAPIBaseURL = @"https://api.myapp.com/";
#endif

It's probably a lot to take in but let me know how you get on.


You can then also create different user defined build settings to do different things, like change the display name of your app.

You could do this by creating a new setting called MYAPP_DISPLAY_NAME for example, set the correct name for each configuration and then in your info.plist set the value of the Bundle Display Name to $(MYAPP_DISPLAY_NAME).