Installing RubyMotion on Circle CI
…or how to install RubyMotion from command line.
A while ago I’ve been assigned to develop an iOS application for a sleep disorder treatment. This app would help patients to keep track of their sleep patterns and daily goals using RoQua questionnaires (in Dutch). Our web-based software is mostly written in Ruby. None of our developers had experience building native iOS apps and neither had we experience with Objective-C or Swift. So we decided to go with RubyMotion for two reasons: we'd keep it all Ruby (including most of the Ruby sauce) and we'd build a native app (which is great for performance). Off course there are some downsides with this approach but that’s a subject for another post.
All of our projects are tested on Circle CI before we proceed with merging pull requests and deployment to our servers. Which is what I would like to achieve with this iOS app: testing and building on a remote Continuous Integration system. Luckily for me Circle CI supports iOS. Unfortunately, they still do not support RubyMotion out of the box, so I spent quite some time and a long email exchange with Circle support (which is great!) to figure it all out.
While installing RubyMotion via the command line, one of the biggest annoyances was RubyMotion GUI installer. This installer is an OS X app and thus runs on OS X, which by the way works great on a desktop environment. As far as I know there’s no way to run this installer via CLI and pass it a license key nor is there a command line installer. With some help of the internets I figured out that `motion update` is actually a curl POST which downloads an executable package that can be run via the command line to install RubyMotion. So basically I ended up reverse-engineering the update script and wrote my own bash script that checks for last version available on their servers and downloads this version.
This script will run each time the build runs, checking if cached downloaded installation package exists for the latest version. Otherwise it downloads the latest version, installs it, and activates it.
Provisioning is quite simple. I included iOS provisioning profile within git repository of the project. When Circle
runs the build, it copies provisioning profile into the
folder. I use an environment variable which sets the path to provisioning profile during the build.
Setting up the project appeared to be quite simple too. There are some Rubygems and Cocoapods dependencies which must be installed in order for this app to work properly. See circle.yml for details:
Right now Circle only tests the software and sends a callback to some other services we use. For example, pull requests on Github know the state of the build and our chat application receives an error when a build succeeds or fails. I would like to take it even further and be able to build a release version of this app in order to deploy it to production devices. But perhaps that will be a subject of my next post.