Travis, Xcode & Schemes

How to configure travis to generate your Xcode schemes

September 20, 2015

Have you ever wanted to generate your Xcode schemes for travis builds? Tired of checking in useless files that are generated for you by Xcode when run? Good. Me too.

On the flair project I use premake to generate my project files. As a part of my build process I run a script that executes premake to generate the Xcode project then hand it off to xctool to complete the build.

xctool and xcodebuild will refuse to build your project if your Xcode schemes are missing. The internet recomended that you check in your schemes so that travis will build your projects. The internet does not have a good enough solution. I do.

We are going to use the xcodeproj ruby gem to generate our schemes as a part of our build process. The magic lies in a bit of configuration and a little helper script.

First, the configuration, in your before_install: collection of the .travis.yml file setup rvm, and install the xcodeproj gem:

  - rvm use 2.1.2
  - gem install xcodeproj

Next, the script:

echo "
 require 'xcodeproj'
 project = '../flair.xcodeproj'
 project = '../tests.xcodeproj'
" | ruby

Add the above script and modify it to open each project you need to generate schemes for. In the flair project I include this code snippet in the bash build script that is run from the install: scalar in the .travis.yml file.