App versioning based on 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 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 the 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.
Screen Shot 2018-04-27 at 1.34.45 pm
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 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

Screen Shot 2018-04-27 at 1.47.10 pm

Staging configuration setup

Screen Shot 2018-04-27 at 1.46.27 pm

Prod configuration setup

Screen Shot 2018-04-27 at 1.46.49 pm
Final configuration setup should be as below. Now close solution and open it again, so the Visual Studio can do all the binding properly.
Screen Shot 2018-04-27 at 1.47.19 pm

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 Build section, you can notice different compiler symbol options are available. We need to set new complier 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.

Screen Shot 2018-04-27 at 2.01.25 pm

For Staging, I Stage Dev as compiler symbol.

Screen Shot 2018-04-27 at 2.02.57 pm

For Production, I have Prod as compiler symbol.

Screen Shot 2018-04-27 at 2.03.53 pm.png

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 right setting for the right environment.
Screen Shot 2018-04-27 at 3.08.08 pm.png

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
Screen Shot 2018-04-27 at 2.06.30 pm.png
We will be creating three different info.plist for our three versions of the app as shown below.
Screen Shot 2018-04-27 at 2.09.24 pm.png
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, dont forget to remove display name from it

Dev

Screen Shot 2018-04-27 at 2.58.32 pm.png

Screen Shot 2018-04-27 at 2.48.57 pm

Stage

Screen Shot 2018-04-27 at 2.59.03 pm.png

Screen Shot 2018-04-27 at 2.50.12 pm.png

Prod:

Screen Shot 2018-04-27 at 2.59.21 pm.png
Screen Shot 2018-04-27 at 2.50.55 pm.png

Edit iOS Proj file

Now go and edit iOS proj file, to edit do as shown in the below screenshot
Screen Shot 2018-04-27 at 2.37.24 pm.png
After opening the proj file, look for info.plist file
Screen Shot 2018-04-27 at 2.39.07 pm.png
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
Screen Shot 2018-04-27 at 2.42.52 pm.png

Output

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

Category:
Mobile
Tags:
,

Comments are closed.