by Khawaja Farooq
How to use Visual Studio Team Services for iOS native apps
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:
- Buildable Xcode project on GitHub / TFS
- VSTS Account
Create a VSTS Project
Create a new team project → Settings > Overview > New team project
The next step is to import your existing repository. For now, we are using GitHub. Click import a repository.
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:
- Homebrew OS X
- .NET Core
- Install npm using command: brew install npm
- Create a Personal Access Token (PAT) and for the scope: Agent Pools (read, manage)
- Create new agent queue “OSX” → Settings > Agent queues
- Download and configure the build agent for OS X.
Once the configuration is done, run the build agent with the following command:
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
Don’t forget to select your agent pool that you just created.
Xcode build definition may look like the following:
Workspace path varies whether you are using an Xcode workspace or just a project.
In case you are using an Xcode workspace:
For an Xcode project:
You can also use some utilities to copy and publish your build artifacts.
Next, save the build definition and queue a new build…
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
Now push the changes to your source control and build again.
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.
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! ?