Continuous Integration with Xcode Bots – Part 1 Initial Setup

icon-bots_2xOne of the more exciting features for iOS developers introduced at WWDC 2013 was continuous integration built into Xcode. Continuous Integration is the practice of merging all developer working copies with a shared mainline several times a day. Continuous Integration is intended to be used in combination with automated unit tests which are run periodically or after every commit to confirm stability of the commit before being added to the mainline.

There are various third-party continuous integration systems out there including Jenkins which work very well across multiple platforms, however Bots are the first to be integrated directly into Xcode and Mac OSX server. If you work on projects across multiple platforms you may be better off looking into a more platform-agnostic solution, but if you do a lot of iOS development Bots could be a great boost to your productivity.

Here at Nitro Mobile Solutions we develop many products targeting iOS and love to work with bleeding edge technology so it was a no brainer that we were going to integrate this into our development process. Being that this feature was just released and not very well tested, I would go as far as saying ?released prematurely?, I ran into a lot of issues in the process of getting this running on our build servers. Since I started in the early beta stage of the software many of the issues I ran into have been fixed, some issues however still remain.

This will be a series of blog posts where I will walk through setting up the Xcode server, connecting to remote/local git repositories, and creating and running bots. Hopefully by following this guide you won?t run into the problems I had, however if you still run into problems all I can say is roll the dice again and hope for better luck :)

Setup a dedicated build server

Of course you can set this up on your development machine but if you plan on using this in a production environment I would advise using a dedicated build machine. First of all, let?s install the minimum software requirements for running bots.

Install Mac OSX Mavericks

Screen Shot 2013-11-19 at 2.52.02 PM

The newest version of Mac OSX can be obtained for free from the Mac App Store https://itunes.apple.com/us/app/os-x-mavericks/id675248567?mt=12. This is pretty straight forward, just download and install the new version.

Install OS X Server 3.0

Screen Shot 2013-11-19 at 2.59.38 PM

The bots are included in the Xcode server functionality of OS X Server 3 for Mavericks. If you are a registered iOS developer, which I would guess most of you are, you can obtain a redeem code from the iOS developer site to download for free from the Mac App Store. If you are not a registered developer you will need to pay $19.99 to obtain it from the App Store.

Install Xcode

The latest version 5.0+ is also required and can be obtained from the Mac App Store for free https://itunes.apple.com/us/app/xcode/id497799835?mt=12.

Setup the Xcode server to use Bots

Screen Shot 2013-11-19 at 3.06.16 PM

Once you have all of the requirements installed go into the Xcode section of the Server app and turn on Xcode server. Click on the ?Choose Xcode? button and find the Xcode app you just installed.

One of the biggest problems developers have had with building iOS apps has always been setting up provisioning profiles. It has always been ?black magic? that sometimes works and most of the time doesn?t work. I have been doing iOS development since the initial beta release of the iPhone OS 1.x SDK, about 6 years now, and I still can?t get it to work every time :( Apple is working to fix this by automating the provisioning process. This actually still doesn?t work all the time but they seem to be making progress.

Screen Shot 2013-11-19 at 3.11.46 PM

In the Developer Teams section, click on the ?Add?? button and enter your Apple ID and password.

Setup the Git repository for your project

Bots work by pulling your code from either a Git or Subversion repository. This can be hosted or local. Warning, I have not been able to get SSH keys to work in this process so you may want to use username/password authentication over SSL. In a future post, I will go into depth on setting up SSH.

Screen Shot 2013-11-19 at 3.32.03 PM

In the next part of my series on setting up Xcode bots I will explain how to create and configure the actual bots, see you then!