Versioning of iOS app (Dev, Stage, and Prod) using same code base – Xamarin Forms

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

Screen Shot 2018-04-27 at 1.34.45 pm

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

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
Screen Shot 2018-04-27 at 1.47.19 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.

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.

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

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

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

Screen Shot 2018-04-27 at 2.06.30 pm.png
Screen Shot 2018-04-27 at 2.09.24 pm.png

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

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

Stage

Screen Shot 2018-04-27 at 2.59.03 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

Screen Shot 2018-04-27 at 2.37.24 pm.png
Screen Shot 2018-04-27 at 2.39.07 pm.png
Screen Shot 2018-04-27 at 2.42.52 pm.png

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

IMG_0038
IMG_0039
IMG_0040
IMG_0041

When we run with the above configurations, it will create different apps for the same code base

 
Github link
https://github.com/divikiran/AppVersioning

Advertisement

Posted

in

by

Tags:

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: