Sunday, May 17, 2015

Setup Continuous Integration for xCode

Just recently we found an old Mac Mini from 2010 in our basement and decided to set it up as a continuous integration server for our iOS APPs (and for Android too, but that's another topic)

The installation is quite simple. Just install Mac OSX, in our case it is an installation of Yosemite, as usual. Then go to the Apple Developer page, download the latest OSX sever dmg and install it on the server. Keep this dmg, because you'll need to install it on every machine that should be able to remotely administer that server (your development mac for instance)

On the server then you just need to enable the "Xcode" service and you're basically done. You could actually use that server as a git repository too, but as it currently has just a single HDD installed we decided to put the git on another server.

The installation process and the creation of a CI-bot is explained quite well by Apple, so I'll not loose a lot of time on that. The reason I write this post is how to cover the special cases that we have in our development procedure.
The CI server does just a normal clone of your git repo, compiles it and runs all the test, but it is not aware of the special cases, that are over there.

Fortunately Apple offers the possibility to add pre-compilation scripts where you can handle this. Because I wasn't sure if I did it right I put my script into this discussion to get feedback on it. Finally I came up with a slightly shorter version.

export LC_ALL="en_US.UTF-8"

if [ ! -e "$HOME/.cocoapods/repos/reponame" ]
    pod repo add reponame https://username:password@path/to/private/Specs.git

cd ${XCS_SOURCE_DIR}/Projectname_without_dot_git

git submodule update --init --recursive

pod update
The command "pod repo add" deals with the private repo spec, then of course the "git submodule update --init --recursive" command which does updates all the submodules and finally the "pod update" which is adding the pods to the project.

However I still get some errors which I can't fix right now. I'll keep you up to date when I'll find a solution to this.

No comments: