by Khawaja Farooq

How to use Visual Studio Team Services for iOS native apps

7TFqKcVsGuZcFOz2zBYfjDQDu1idnZFkGlN4

Visual Studio Team Services (VSTS) provides an easy way to share code, automate builds, run unit tests, and ship software. Developers from a wide range of platforms rely on it. It promotes continuous integration, which can accelerate the process from concept to delivery.

Microsoft has done a substantial amount of work to improve DevOps for Mobile and other platforms. However, there are no specifics for the iOS native platform. Here’s a guide on how to set up VSTS for an iOS project, so you can leverage its continuous integration capabilities.

Here are the pre-requisites to get started:

  1. Buildable Xcode project on GitHub / TFS
  2. VSTS Account

Create a VSTS Project

Create a new team project → Settings > Overview > New team project

5A8zGgcE0E9K8mDwFCz5BXOaDQ7vd6SFb0Gl

The next step is to import your existing repository. For now, we are using GitHub. Click import a repository.

1d1RSYgmeYA-ZfyKTc6G8XYthoZYEw7X5S0w

Now you have your own copy of the repository that you should be able to see!

Install the iOS Build Agent

VSTS doesn’t have any preinstalled agent for building an Xcode project. This part is crucial.

Fortunately, the configuration is covered by James Montemagno for Xamarin iOS. For convenience, I’m quoting some of the steps here.

You’ll need to install the following items to prepare your Mac:

  1. Homebrew OS X
  2. .NET Core
  3. Install npm using command: brew install npm
  4. Create a Personal Access Token (PAT) and for the scope: Agent Pools (read, manage)

Agent Queue

  1. Create new agent queue “OSX” → Settings > Agent queues
  2. Download and configure the build agent for OS X.
NAUNW7VQqw2hrykcwebAuOGtM2d0vR6LtTPf

Once the configuration is done, run the build agent with the following command:

./run.sh

Well done! You have an on-premise build agent running.

Create the Xcode Build Definition

Once you have installed the build agent, it’s time to create a build definition. These steps will create a build definition for Xcode iOS instead of Xamarin. Go to → Build & Release > New Definition > Xcode

4LvE4SuRG5N0qxdYKwSQUlhVCi0USraGR6Cr

Don’t forget to select your agent pool that you just created.

56A8HwKcOuabTD90G6YtIlANIbjgL8yjOn30

Xcode build definition may look like the following:

yvVzVxSGbdcjjCZYdqMq8-2tT5eAM6-LdkWb

Workspace path varies whether you are using an Xcode workspace or just a project.

In case you are using an Xcode workspace:

*.xcodeproj/project.xcworkspace

For an Xcode project:

*.xcodeproj

You can also use some utilities to copy and publish your build artifacts.

Next, save the build definition and queue a new build…

2RpYOp-3o9-teatL7pMOdGdQC07Ib0zcgNlf

You should get a build error. We need to make one change to the Xcode project configuration.

Configure the Xcode project/workspace

VSTS needs a shared project scheme in order to build the project. Make sure to enable it. Xcode Product > Schemes > Manage schemes

KMojWE198TJHgM6B7MB-IIoBfqMy10Lp3taL

Now push the changes to your source control and build again.

y0IatW3Lfq-dKdu1xlu0TeYwoMxr57Aray42

Deploy to HockeyApp

HockeyApp helps testers for beta app testing. It’s easy to install the VSTS Extension from the marketplace. This enables the app to be uploaded after it builds successfully.

8F1g9Qo9BhY-YvAPtarq-eBfjwcbNca1ntny

Download & import sample build definition

Visual Studio Team Services provides continuous integration for iOS developers. By automating a lot of repetitious tasks, it saves you time.

Another option is MacinCloud, a cloud solution for building iOS native apps. For now, we have reviewed on-premise build capabilities as Azure doesn’t provide VM support for Mac OS X. Give VSTS a try and leave any feedback in the comments or get in touch on twitter @khfarooq, that’s what keeps me going. Thanks for reading! ?