Continuous Deployment for iOS Apps

In Lean Manufacturing, inventory is waste.  Inventory is product that you have built but have to store because you can’t get it into the hands of customers.

There is a similar concept in Lean Development.  Any code that has been written but is not in the hands of users is inventory.  And inventory is waste.

Continuous Deployment is the process of getting code that is written in to the hands of users as quickly as possible.  It is one layer of discipline on top of Continuous Integration.

Continuous Deployment is difficult for iPhone Apps because of the App Store approval process.  It is also difficult to automatically test and code sign Apps.  There are a number of tools to help with this process: KIF, Github, Jenkins, xcodebuild, and TestFlight.

Integration Tests

Square has a great integration testing framework called KIF: Keep It Functional.  The source code is available on Github.  There is also a great Google Group.  The README file should have enough information to get KIF up and going with your Xcode project.

KIF uses the accessibility functionality of iOS to to automatically test the UI.  You do make your App accessible, right?  Right.

Once you have accessibility labels for your controls you can write test cases that automatically exercises the UI.

Github

You should be using git for source code revision control.  And if you are using git then you should be storing your code at Github.  Github has a number of web hooks that will POST to a URL when code is pushed to a repository.

This web hook can be pointed at Jenkins.

Jenkins

Jenkins (formerly Hudson) is a continuous integration server.  My favourite way to install Jenkins on a Mac is to use Homebrew.

$ brew install jenkins
$ java -jar /usr/local/Cellar/jenkins/1.447/lib/jenkins.war

Yeah, I know, Java.  Bear with it.

Now you need to tell Jenkins to execute a bash script for every build.

I’ve XXXX’d out some variables.  You should fill those in with correct App name, Scheme, Target, etc.  Also, you will want to keep your .mobileprovision file in your git repository.

The build script relies on xcodebuild and xcrun to build and sign the App.

$ man xcodebuild
$ man xcrun

TestFlight

The last piece of the puzzle is TestFlight.  TestFlight is an App management dashboard.  It manages a list of your Apps and your testers.  It sends out emails to testers whenever a new build is available.

Testers are able to install Ad Hoc builds directly from their iPhone.

It lets you creep on your testers.  You know exactly when a tester last installed a build.  This allows you to yell at your testers when they have been slacking off.

The build script uploads the .IPA file up to TestFlight.  TestFlight has fairly good documentation for their Upload API.

It also uploads the .dSYM symbol file. TestFlight will symbolicate crashes that are uploaded to their servers.  You need to integrate the TestFlight SDK to take advantage of this functionality.

Conclusion

Continuous Deployment is key for eliminating waste in your development process.  It is key if you want to keep moving fast as you scale up the size of your code base and the size of your team.  It is best to implement it sooner rather than later.  Frankly, you should implement Continuous Deployment before you write a line of code.