Skip to content

Configuring the Virtual Machine to Build iOS Apps

Simon Støvring edited this page Jun 19, 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 robotsandpencils/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 14.2. Remember to replace the version number with the version you wish to install.

xcodes install 14.2

ℹ️ 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 14.2

5. Install SwiftLint

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 Ruby using RVM

We use RVM to manage the Ruby version used by the virtual machine. First we install GnuPG as we will need that in a second.

brew install gpg

Then we add RVM's GPG keys.

gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Then we can install RVM by running the following command.

curl -sSL https://get.rvm.io | bash -s stable

And finally we can install the latest stable version of Ruby. In this case we install Ruby 3.2.0.

rvm install 3.2.0

8. Install Node with NVM

We use NVM to manage the Node version used by the virtual machine. Install NVM by running the following command.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

The install the latest stable version of Node. In this case we install Node 18.13.0.

nvm install 18.13.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. 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.

12. 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.

Clone this wiki locally