Skip to content

Configuring the Virtual Machine to Build iOS Apps

Simon B. Støvring edited this page Dec 17, 2023 · 21 revisions

After going through the Installing Tartelet and Configuring Tartelet articles, you are now ready to start the GitHub Actions runners. However, if you are planning to use the runners to build iOS apps, you will need to do some additional configuration on the virtual machine.

This article describes the additional steps we have performed at Shape to configure the virtual machine to build iOS apps.

1. Install Homebrew

We install Homebrew for two reasons:

  • Throughout this article we will use it to install software.
  • Our workflows may use Homebrew to install software they depend on.

Run the following command to install Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Remember to follow the steps printed by Homebrew after the installation to finalize the setup.

Disable automatic updates

By default Homebrew will automatically update packages when installing another package using brew install. We want to disable this for two reasons:

  1. It means that our workflows are not always running with the same versions of the installed software.
  2. It increases the duration of our workflows.

Follow the steps below to prevent Homebrew from automatically update installed packages.

  1. Open the file at ~/.zshrc.
  2. Add a line to the file with the content export HOMEBREW_NO_AUTO_UPDATE=1.
  3. Save the file.
Disable automatic cleanup

We also want to make sure that Homebrew does not automatically cleanup the installed packages. We disable this as it increases the duration of our workflows.

Follow the steps below to prevent Homebrew from automatically cleaning up packages.

  1. Open the file at ~/.zshrc.
  2. Add a line to the file with the content export HOMEBREW_NO_INSTALL_CLEANUP=1.
  3. Save the file.

2. Install xcodes

We use xcodes to install new versions of Xcodes on the virtual machine. Install xcodes by running the following command.

brew install xcodesorg/made/xcodes

3. Install aria2

Install aria2 to have xcodes download versions of Xcode faster. This is mentioned in the README in xcodes' repository. Install aria2 by running the following command.

brew install aria2

4. Install the latest version of Xcode

Use xcodes to install the latest version of Xcode. The command below installs Xcode 15. Remember to replace the version number with the version you wish to install.

xcodes install 15.0

ℹ️ Note

By default xcodes names the installed app something like Xcodes-14.2.app with dashes. However, the GitHub runners uses underscores instead of dashes. We do the same at Shape to keep our runners as close to GitHub's runners as possible. Therefore we rename the app after xcodes has successfully installed it.

Then make the installed version the default by running the following command. Once again, replace the version number with the version of Xcode you installed.

xcodes select 15.0

Finally, install the relevant runtimes. For example, you may want to install the iOS 17 runtime.

xcodes runtimes install "iOS 17.0"

5. Install xcbeautify

Install xcbeautify by running the following command.

brew install xcbeautify

6. Install SwiftLint

Install SwiftLint by running the following command.

brew install swiftlint

7 Install asdf

We use asdf to manage the runtime versions of Ruby and Node.

Install asdf by following the official instructions. As of writing this, the official instructions are to run a shell command which contains the latest version number of asdf and as such is not suitable to be included in this guide.

7. Install Ruby using asdf

We use asdf to manage the Ruby version used by the virtual machine.

Start by adding the dependencies of Ruby as per this issue in asdf-vm/asdf-ruby repository.

brew install zlib readline libyaml libffi

Then add the Ruby plugin to asdf.

asdf plugin add ruby

Then install the latest stable version of Ruby. In this case we install Ruby 3.2.2.

asdf install ruby 3.2.2

Make sure the installed version is selected globally.

asdf global ruby 3.2.2

8. Install Node using asdf

We use asdf to manage the Node version used by the virtual machine. Start by adding the Node plugin to asdf.

asdf plugin add nodejs

Then install the latest stable version of Node. In this case we install Node 18.18.0.

asdf install nodejs 18.18.0

Make sure the installed version is selected globally.

asdf global nodejs 18.18.0

9. Install fastlane

Most of our projects use fastlane to build the app, manage signing, and more. Install fastlane by running the following command.

brew install fastlane

10. Install jq

jq is a JSON processor that some of our workflows and actions may use to work with JSON. Install it by running the following command.

brew install jq

11. Install Git Large File Storage

git-lfs is used to store large files in Git. Install it by running the following command.

brew install git-lfs

12. Install GitHub CLI

GitHub CLI is used for performing operations towards GitHub.

brew install gh

13. Install ImageMagick

ImageMagick is used to edit images. Install it by running the following command.

brew install imagemagick

14. Add GitHub's hostname to ~/.ssh/known_hosts

Make sure GitHub's hostname is added to ~/.ssh/known_hosts by running the following command. This ensures that the machine can clone repositories when running a job.

ssh github.com

The select "yes" when asked to confirm.

15. Configure Git with a username and email

Configure the Git installation with a username and email. This is used when committing changes from the runner.

Start by configuring the username.

git config --global user.name <name>

Then configure the email.

git config --global user.email <email>

We use the following information at Shape.

Field Value
Name runner
Email [email protected]

16. Install the Worldwide Developer Relations - G3 certificate

The Worldwide Developer Relations - G3 certificate is needed by all iOS developers to sign apps. Follow the steps below to install the. certificate.

  1. Download the certificate from https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
  2. In case the certificate was not downloaded directly to the virtual machine, then transfer it to the virtual machine.
  3. Run the following command. Remember to pass the correct path to the certificate.
sudo security import ~/Downloads/AppleWWDRCAG3.cer ~/Library/Keychain/login.keychain-db

Next Steps

That is all! The next step is to start building your iOS apps on your self-hosted runner.