App versioning based on the same code base is the favorite feature of most of the clients I worked for various reasons. Usually, this feature is requested to cater App to the different set of departments or support multi-tenancy that client want to support. When creating a complex app, there are n-number of teams working together to build it, which includes dev testers, beta testers, or even a client who wants to demo a product before actually purchasing it. Having a single app does not support the purpose, as a client may want to cherry-pick different features to be available in the different version of the app.
In this blog, I will be sharing about how to create a different version of the app in iOS, I will do a different blog of Android. For this purpose, initially, we need to setup configurations for each required App version we want to support.
Set different configurations

In Mac, double-clicking on the solution level will prompt us with Solution Options dialog, and go to Configurations in the Build section. Go to Configurations tab as shown in the screen below.
As you can notice for a new project, there are two configuration settings available as Debug and Release for various platforms. if you go to the General tab, you can find all the available configurations broken down. Also, you can find options to add new, copy, remove and rename configurations. As per our requirements, we will Dev, Staging and Production configurations. Usually, we need the only version for iPhone, therefore create Configurations for iPhone only.
Dev Configuration setup

Staging configuration setup

Prod configuration setup


Final configuration setup should be as below. Now close solution and open it again, so the Visual Studio can do all the binding properly.
Complier symbols options:
Symbols are used along with the directives to compile code as per the given conditions, just like if-else condition. If you can double click on the iOS project, a dialog box called project options will be opened. If you go to Compiler tab under the Build section, you can notice different compiler symbol options are available. We need to set new compiler names for our newly created configurations. This can be done by selecting the required configuration and adding relevant Symbol to it, as shown in below screenshot.
For Dev, I have Dev as compiler symbol.

For Staging, I Stage Dev as compiler symbol.

For Production, I have Prod as compiler symbol.

Purpose

Now, that we have setup configurations, we can write code as shown below and whenever different configuration builds are made, it will automatically pick the right setting for the right environment.
Info.plist


Info.plist is the file that dictates what configurations are to be applied to the concerned app. Original info.plist can be found setup as below
We will be creating three different info.plist for our three versions of the app as shown below.
To keep thing simple, just change the CFBundleIdentifier to relevant names, in this case, I will be appending with Dev, Stage, and Prod to current Identifier. Also, don’t forget to remove display name from it
Dev

Stage

Prod:


Edit iOS Proj file



Now go and edit iOS proj file, to edit do as shown in the below screenshot
After opening the proj file, look for info.plist file
Now add the conditions to them according to each platform and move the newly created info.plist’s above the original info.plist or else it will take first available plist as shown below
Output




When we run with the above configurations, it will create different apps for the same code base
Github link
https://github.com/divikiran/AppVersioning
Leave a Reply