Xamarin Forms – App Center: Show BuildID on iOS App

Introduction

App center helps us to connect support git repositories (i.e GitHub, Bitbucket or VSTS)  and build the app for us either on every code commit or manually. It also sends notifications to users that are registered to it. It will also help us to run tests on the actual device and runs any unit tests in the project.

iOS and Android

App Center can be set up to build individual platforms projects.

Scenario:

Screen Shot 2018-01-03 at 19.57.00

Required to show BuildID on iOS APP during the development phase, as shown below. This was required to keep track of bug reports or any other reason.

Show App Center Build ID in iOS app

Info.plist

Screen Shot 2018-01-03 at 20.18.13

Below is the BuildID that is read when traditional approach as below

Traditional Approach:

Screen Shot 2018-01-03 at 20.21.56

This can be achieved by implementation natively on each platform and used via interfaces in PCL or .Net standard projects, as shown below.

Native Implementation:

Screen Shot 2018-01-03 at 20.25.39


The above code will return the App Version and App build number that are set in the info.plist.

Get BuildID from App Center

Screen Shot 2018-01-03 at 20.34.21
Screen Shot 2018-01-03 at 20.36.42

This can be achieved using post clone and pre-build – Build scripts, which can be set in the App center’s build configurations as shown below

Post Clone

Below is the post clone code to load App Center’s CLI, which is required to be named as appcenter-post-clone.sh.
#!/usr/bin/env bash
npm install -g appcenter-cli

Pre-Build

Screen Shot 2018-01-03 at 21.20.35
build id

Below is the pre-build code that set’s the info.plist’s Build number with App Centers BuildID
plutil -replace CFBundleVersion -string “$APPCENTER_BUILD_ID“ $APPCENTER_SOURCE_DIRECTORY/path to ios project/Info.plist
APPCENTER_BUILD_ID is the App Center variable that contains BuildID, below is the BuildID that is set to  CFBundleVersion
The most recent Build number as shown below is replaced and set to CFBundleVersion.

After downloading from App center, iOS should show the latest build number as shown in below screenshot.

I hope you like the post.

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: