I have started using GitHub Actions for CI on a new project as a replacement for my usual setup on Travis CI. It generally seems to be much faster and more reliable so far. It also has an equivalent feature set, as far as I can tell. But one issue that I have run into is selecting a specific Xcode version, which is a bit cumbersome and not fully documented.

I searched GitHub’s workflow syntax documentation but did not find anything mentioning Xcode versions. I discovered the documentation that specifies the software installed on GitHub-hosted machines. There is a full spec for macOS that lists all the installed software and SDKs, which is convenient and well-organized. It clearly specifies the available Xcode versions that are installed, but fails to mention how to specify one for your workflow.

The only option seemed to be adding a build step to run xcode-select. It did not seem correct. Given my experience with Travis CI and other similar services, not to mention the popularity of Apple platform projects on GitHub, I thought it was odd that GitHub would omit a way to configure this.

I resorted to an old strategy — the same one I used to learn how to setup Travis CI for the first time long ago — look at a popular Swift or Objective-C project and see how they are doing it. I noticed that Alamofire had recently switched from Travis CI to GitHub Actions, and the answer was there in their workflow yaml file. Apparently, you can set the DEVELOPER_DIR environment variable. You can specify any version listed here.

name: CI
on: [push]
  DEVELOPER_DIR: /Applications/Xcode_11.2.app/Contents/Developer

  # specify jobs...

Now that I knew what I was looking for, I wanted to work backwards to find the docs. There is this page on using environment variables, but there is no mention of DEVELOPER_DIR. In fact, I searched all of the GitHub docs on actions and workflows that I could find. There was no mention of DEVELOPER_DIR anywhere, except for this GitHub community forum post. Unsurprisingly, the question was asked by Jon Shier, who is a top contributor to Alamofire and the author of the change switching the project to GitHub Actions for CI.

Compared with other services, this feels odd and it is unclear why there is no explicit documentation for such a common and necessary task for Apple platform projects. However, the GitHub team does seem to be responsive to feedback and feature requests. It would be great to see Xcode version selection improved, but at least it is possible.