Thursday, November 7, 2013

Using Cocoapods with Xcode Bots

I just finished setting up builds using Xcode bots this morning for our app which uses cocoa pods, however I will say that we are going to stick with Jenkins.  So far my impression of bots is that they are meant for people who have never done CI before.  They are EXTREMELY limited in capability (can’t monitor a build as it’s happening, build env can’t pass parameters to the build such as build numbers, can’t run scripts pre/post build etc, can’t administer a list of people allowed to download your test app, Xcode build list not auto-refreshed when new build is run, etc).  

Looks like the only thing you can do is what you can add to your build scheme, and the only feature benefit is Xcode integration (which sucks so far, was not even able to create a bot in Xcode, had to use web page) so you can link from automated test runs to source code.  Neither of these warrant moving from Jenkinsish/Testflight solutions.

All that is why we are NOT converting to bots, but if you want to use cocoa pods with bots here’s what I had to do:

  1. go through the voodoo of setting up os x server and Xcode automation
    1. create home folder /var/teamsserver for _teamsserver user if it doesn’t already exist
    2. make sure to set proper ownerships on /var/teamsserver to _teamsserver account
  2. add .ssh with keys that can access your local pod repo to /var/teamsserver
  3. Set up new schemes specifically for Xcode bots
    1. edit scheme / build / pre-action add a bash script (or other script, your choice) that does something like
    2. if ~/.cocoapods/repos/localrepo does not exist, pod repo add your local repo
    3. if Pods folder does not exist pod install, else pod update
  4. share and check in the scheme
  5. Go http://yourserver/xcode and create the bot.
    1. create bots via xcode server web page… Xcode never let’s you get past authentication settings even when it shows them correct (this may be because we don’t allow HTTP urls on our github server, only ssh, so our url looks like git@ourserver.com:Team/App)

Fairly short list of steps, but OS X server docs were no help at all.  

I’m really hoping this is just the starting point for bots, and that they will get a lot better in the future.  Currently, even though jenkins is a much more complex CI server, I found myself pulling my hair out less setting up Jenkins than I did Xcode bots.  Jenkins also supports something called a config matrix so you can run multiple build configs on a single checkout.

BTW, here's what my build pre-action script looks like:

cd $SRCROOT

if [ ! -e "$HOME/.cocoapods/repos/OurRepo" ]
then
    pod repo add OurRepo git@ourgithub:OurApps/CocoaPodSpecs.git
fi

if [ -e "Pods" ]
then
    pod update
else
    pod install
fi