Publishing an application not an easy task there are many phases under which the app needs to go. Such as development, testing, etc. Out of that, testing the application is a major task to make the application stable. While testing it we actually maintain different servers(staging, production, development, etc) that we only use while developing and in testing. But when times come where the client wants the final build where we have to change all setup of the server URL and other stuff which we using while testing to Production set. During this time developers have to do it manually by changing the URL. What if we got a chance where we don’t need to do this all manual work. Yes!, You can do it that is what we are going to discuss it here.

There are multiple ways/approaches to provide a build for testing and for production.

Target

Each project has one or more target where it contains a list of classes, assets, etc. Target is another application with an enhanced feature of the current app or we can say the same application with different names, bundle id. Or we can say a copy of the project which we are providing it to other clients.

Build Scheme

A build scheme is a collection of targets to build an application, it is a configuration to use when building, and a collection of tests to execute.

Build Configuration

Is a kind of setting that can be applied to target.

Build Configuration and Build Scheme

These two things we must have to use when we are using the different-different environments. Let’s start setting up the environment. The following are the basic steps we need to perform.

  1. Create a different build configuration in the project editor.
  2. Create a different scheme for each build configuration.
  3. Create a .xconfig file.

1.Create a single view application

Create an app on how you are creating it normally. By default you can see the two build configuration with Debug and Release.

2.Create different build configurations in the project editor.

As you have seen two build configurations created now you can add it by clicking the plus button and selecting duplicate Debug configuration or Duplicate Release configuration as per your choice.

3.Create a different scheme for each build configuration.

Now click on the current scheme located at the top left corner. Click on that you can see a drop-down of Edit scheme, New scheme.

4.Create .xconfig file

This file plays important role in the environment setup. From this file, we are actually fetching the values for each environment separately.

NOTE

Make sure that in build configuration for each configuration we have selected the right configuration. Check the following screen-shot.

Conclusion

Using Xcode configuration files is an efficient and powerful solution for configuring different build settings. This is a good practice to get rid of manual work. I recommend you should always do these setup before starting any project which helps you to be a good developer.

Sr. Software Engineer @Mindbowser

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store