# Register a GitLab CI Runner on a Hosted Mac

Canonical: https://figment.so/blog/mac-gitlab-ci-runner-macos

Install gitlab-runner on the Mac while signed in locally, register it as a shell executor with a tag, and target that tag in .gitlab-ci.yml. A $39 Apple Silicon Mac VM costs less than GitLab's M1 medium runner past about 650 minutes a month.

**To run GitLab CI on your own Mac, install `gitlab-runner` while signed in locally, register it as a shell executor with a tag such as `mac-arm64`, and target that tag from `.gitlab-ci.yml`.** GitLab SaaS also offers hosted macOS runners, but jobs consume compute minutes at a multiplied rate on fixed hardware. A self-hosted shell runner gives your team a persistent macOS environment with no per-minute meter. This guide covers the break-even, install, registration, Xcode selection, a working pipeline and the security pattern for a shared Mac.

## When does a self-hosted Mac cost less than GitLab SaaS minutes?

For GitLab's M1 medium runner, a Figment Apple Silicon Mac VM at $39 a month breaks even at 650 minutes, or 10.8 hours of macOS build time a month. GitLab's hosted macOS runners multiply job duration by a cost factor before debiting your quota. [GitLab's compute minutes documentation](https://docs.gitlab.com/ci/pipelines/compute_minutes/) lists macOS **M1 medium at 6×** and macOS **M2 Pro large at 12×**, both marked Beta at time of writing, so check the page before you commit. Additional compute minutes on [GitLab's pricing page](https://about.gitlab.com/pricing/) cost **$10 per 1,000 minutes**, which is $0.01 per compute minute.

One minute of real time on an M1 medium runner costs 6 × $0.01 = **$0.06** once your included quota is used up, and one minute on an M2 Pro large runner costs 12 × $0.01 = **$0.12**.

| Figment plan | Monthly | Break-even vs M1 medium ($0.06/min) | Break-even vs M2 Pro large ($0.12/min) |
|---|---|---|---|
| Intel Mac VM | $25 | $25 ÷ $0.06 = 416 min (6.9 hours) | $25 ÷ $0.12 = 208 min (3.5 hours) |
| Apple Silicon Mac VM | $39 | $39 ÷ $0.06 = 650 min (10.8 hours) | $39 ÷ $0.12 = 325 min (5.4 hours) |
| Dedicated M4 Pro 48 GB | $349 | $349 ÷ $0.06 = 5,817 min (96.9 hours) | $349 ÷ $0.12 = 2,908 min (48.5 hours) |

Above those volumes, a self-hosted runner costs less than buying extra minutes, and the quota stops being a release-day bottleneck. This is a price comparison, not a same-hardware claim. GitLab's runners are specific M1 and M2 Pro classes. The Apple Silicon Mac VM has 4 shared vCPUs and 4GB RAM, and the Dedicated M4 Pro 48 GB is a whole Mac with an M4 Pro chip and 48GB RAM.

## How do I install gitlab-runner on macOS?

Install it from Homebrew, or download the binary. Both paths are in [GitLab's macOS installer guide](https://docs.gitlab.com/runner/install/osx.html):

```bash
brew install gitlab-runner
gitlab-runner --version
```

Or install the binary directly (on an Intel Mac VM, GitLab's download page offers a `darwin-amd64` build instead of `darwin-arm64`):

```bash
curl -Lo /usr/local/bin/gitlab-runner \
  https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64
chmod +x /usr/local/bin/gitlab-runner
```

GitLab's docs require that you do this while **signed in locally** to the Mac, in a local terminal or screen-sharing session, not over SSH. The shell executor runs as a user-mode `LaunchAgent` and needs an active user session to reach the Keychain and Simulator. On a Figment Mac, open Terminal through the encrypted remote desktop or browser access, even though SSH is also available on every plan.

## How do I register the runner with a tag?

Create a project runner token in GitLab under **Settings → CI/CD → Runners → New project runner**. Choose a tag such as `mac-arm64` (or `mac-intel` on an Intel Mac VM) and copy the token. Then run:

```bash
gitlab-runner register
```

Answer the prompts:

- **GitLab instance URL:** `https://gitlab.com` or your self-managed URL
- **Authentication token:** the project runner token
- **Description:** `figment-mac-arm64`
- **Tags:** `mac-arm64`
- **Executor:** `shell`

The resulting `~/.gitlab-runner/config.toml` should look like this:

```toml
[[runners]]
  name = "figment-mac-arm64"
  url = "https://gitlab.com"
  token = "glrt-xxxxxxxxxxxx"
  executor = "shell"
  [runners.cache]
```

Install the LaunchAgent and start it:

```bash
gitlab-runner install
gitlab-runner start
```

Enable automatic login so the agent is available after a reboot. Otherwise the runner stays offline until someone signs in. Confirm the runner is online and picked up by its tag in **Settings → CI/CD → Runners** before you point a release branch at it.

## How do I select the Xcode version per job?

Set `DEVELOPER_DIR` as a job variable instead of switching system-wide with `xcode-select`. Parallel jobs can then target different Xcode versions on the same runner without racing each other:

```yaml
variables:
  DEVELOPER_DIR: /Applications/Xcode_26.0.app/Contents/Developer
```

Confirm the path on the Mac before you commit it:

```bash
ls /Applications/ | grep -i Xcode
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" \
  /Applications/Xcode_26.0.app/Contents/Info.plist
```

Intel Macs are limited to Xcode 26 or earlier per Apple's [porting guide](https://developer.apple.com/documentation/apple-silicon/porting-your-macos-apps-to-apple-silicon). Check the exact Xcode and macOS pair you need against Apple's release notes before you pin it in CI.

## What does a working .gitlab-ci.yml look like?

Replace `MyApp`, the workspace path and the scheme with your project's values before you commit. The example is illustrative; run it against your repository and fix whatever your build reports.

```yaml
stages: [build, test, upload]

variables:
  DEVELOPER_DIR: /Applications/Xcode_26.0.app/Contents/Developer
  DERIVED_DATA: ${CI_PROJECT_DIR}/.derived-data

default:
  tags: [mac-arm64]

cache:
  key:
    files: [Podfile.lock]
  paths:
    - Pods/
    - vendor/bundle/

build_ios:
  stage: build
  script:
    - set -euo pipefail
    - pod install --deployment
    - xcodebuild archive
        -workspace "$APP_WORKSPACE"
        -scheme    "$APP_SCHEME"
        -configuration Release
        -archivePath build/MyApp.xcarchive
        -derivedDataPath "$DERIVED_DATA"
  artifacts:
    paths: [build/MyApp.xcarchive]
    expire_in: 1 day

test_ios:
  stage: test
  script:
    - set -euo pipefail
    - mkdir -p test-results
    - xcodebuild test
        -workspace "$APP_WORKSPACE"
        -scheme    "$APP_SCHEME"
        -destination "platform=iOS Simulator,name=iPhone 16,OS=latest"
        -derivedDataPath "$DERIVED_DATA"
        -resultBundlePath test-results/TestResults.xcresult
  artifacts:
    when: always
    paths: [test-results/]
    expire_in: 1 week

upload_testflight:
  stage: upload
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  script:
    - set -euo pipefail
    - bash ci/export-ipa.sh
    - xcrun altool --upload-app
        --type ios
        --file "$(find build/export -name '*.ipa' | head -1)"
        --apiKey "$ASC_API_KEY_ID"
        --apiIssuer "$ASC_API_ISSUER_ID"
  dependencies: [build_ios]
```

`APP_WORKSPACE` and `APP_SCHEME` live in GitLab CI/CD variables, not in the YAML, so a forked project uses its own scheme. `set -euo pipefail` makes every stage fail fast, so a failed build is never timed as a successful benchmark.

## How do I protect secrets on a shared Mac?

The shell executor runs as the macOS user who registered the runner, with full access to that user's Keychain and home directory. Treat the runner account like any other production credential.

| Risk | Mitigation |
|------|-----------|
| CI job reading a developer's signing certificate | Register the runner under a dedicated `ci` account; import the CI signing identity only there, as an encrypted `.p12` with its private key, and place the provisioning profile file in `~/Library/MobileDevice/Provisioning Profiles/` |
| Secrets leaked through job logs | Store API keys as GitLab CI/CD variables marked **Masked** and **Protected**; never `env > .env` to a plaintext file, because it will include credentials. Reference each required secret by name and let your secret manager populate it |
| Jobs reading each other's workspace | Set `builds_dir` under `[[runners]]` in `config.toml` to a project-scoped path, or dedicate a runner per project |
| Allowlists on third-party services | Update your own artifact store, package registry or internal services to accept the Mac's egress IP. There is no published App Store Connect or TestFlight inbound IP range to allow, because uploads originate from the Mac |

## Which Figment Mac plan fits this pipeline?

Use the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($0.40 an hour, $6 a day, $39 a month) for a single shell executor on current Xcode, and the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) ($349 a month) for heavy or parallel pipelines. The [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month) runs macOS Sequoia and fits only when your pipeline stays on Xcode 26.3 or earlier; it cannot run arm64-only binaries or visionOS. Figment runs the Mac; you manage the runner, your GitLab project and your CI configuration, and we do not offer managed CI. Check the macOS version shown before purchase against Apple's Xcode table.

**Related guides**

- [Xcode Cloud vs Self-Hosted Cost](/blog/mac-xcode-cloud-vs-self-hosted-cost)
- [Build Queue with Multiple Runners](/blog/mac-ci-build-queue-multiple-runners)
- [Xcode on Windows: Remote Mac Setup](/blog/mac-xcode-on-windows-remote-setup)
