Set up macOS runners

To run a CI/CD job on a macOS runner, complete the following steps in order.

When you’re done, GitLab Runner will be running on a macOS machine and an individual runner will be ready to process jobs.

  • Change the system shell to Bash.
  • Install Homebrew, rbenv, and GitLab Runner.
  • Configure rbenv and install Ruby.
  • Install Xcode.
  • Register a runner.
  • Configure CI/CD.


Before you begin:

  • Install a recent version of macOS. This guide was developed on 11.4.
  • Ensure you have terminal or SSH access to the machine.

Change the system shell to Bash

Newer versions of macOS ship with Zsh as the default shell. You must change it to Bash.

  1. Connect to your machine and determine the default shell:

    echo $SHELL
  2. If the result is not /bin/bash, change the shell by running:

    chsh -s /bin/bash
  3. Enter your password.
  4. Restart your terminal or reconnect by using SSH.
  5. Run echo $SHELL again. The result should be /bin/bash.

Install Homebrew, rbenv, and GitLab Runner

The runner needs certain environment options to connect to the machine and run a job.

  1. Install the Homebrew package manager:

    /bin/bash -c "$(curl "")"
  2. Set up rbenv, which is a Ruby version manager, and GitLab Runner:

    brew install rbenv gitlab-runner
    brew services start gitlab-runner

Configure rbenv and install Ruby

Now configure rbenv and install Ruby.

  1. Add rbenv to the Bash environment:

    echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
    source ~/.bash_profile
  2. Install Ruby 2.74 and set it as the machine’s global default:

    rbenv install 2.7.4
    rbenv global 2.7.4

Install Xcode

Now install and configure Xcode.

  1. Go to one of these locations and install Xcode:

  2. Agree to the license and install the recommended additional components. You can do this by opening Xcode and following the prompts, or by running the following command in the terminal:

    sudo xcodebuild -runFirstLaunch
  3. Update the active developer directory so that Xcode loads the proper command line tools during your build:

    sudo xcode-select -s /Applications/

Register a runner

Now register a runner to start picking up your CI/CD jobs.

  1. In GitLab, on the top bar, select Main menu > Projects or Main menu > Groups and find your project or group.
  2. On the left sidebar, select Settings > CI/CD.
  3. Expand Runners.
  4. Note the URL and registration token.
  5. In a terminal, start the interactive setup:

    gitlab-runner register
  6. Enter the GitLab URL.
  7. Enter the registration token.
  8. Enter a description for the runner. You will use the description to identify the runner in GitLab, and the name is associated with jobs executed on this instance.

  9. Enter tags, which direct specific jobs to specific instances. You will use these tags later to ensure macOS jobs run on this macOS machine. In this example, enter:

  10. Type shell to select the shell executor.

A success message is displayed:

> Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

To view the runner, go to Settings > CI/CD and expand Runners.

Configure CI/CD

In your GitLab project, configure CI/CD and start a build. You can use this sample .gitlab-ci.yml file. Notice the tags match the tags you used to register the runner.

  - build
  - test

  LANG: "en_US.UTF-8"

  - gem install bundler
  - bundle install
  - gem install cocoapods
  - pod install

  stage: build
    - bundle exec fastlane build
    - macos

  stage: test
    - bundle exec fastlane test
    - macos

The macOS runner should now build your project.