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:

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.
Screen Shot 2018-01-03 at 19.57.00

Show App Center Build ID in iOS app

Info.plist

Below is the BuildID that is read when traditional approach as below
Screen Shot 2018-01-03 at 20.18.13

Traditional Approach:

This can be achieved by implementation natively on each platform and used via interfaces in PCL or .Net standard projects, as shown below.
Screen Shot 2018-01-03 at 20.21.56

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

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
Screen Shot 2018-01-03 at 20.34.21
Screen Shot 2018-01-03 at 20.36.42

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

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 contain’s BuildID, below is the BuildID that is set to  CFBundleVersion
The most recent Build number as shown below is replaced and set to CFBundleVersion.
Screen Shot 2018-01-03 at 21.20.35
After downloading from App center, iOS should show the latest build number as shown in below screenshot.
build id
I hope you like the post.
 

Category:
Mobile
Tags:
, ,

Leave a Reply

Follow ...+

Kloud Blog - Follow

%d bloggers like this: