# Self-Hosted Mac Runner for GitHub Actions

Canonical: https://figment.so/blog/mac-github-actions-self-hosted-runner

Download the runner from your repository's Settings, register it with labels, install it as a launchd service and target it with runs-on. Past about 629 build-minutes a month, a $39 Apple Silicon Mac VM costs less than hosted macOS minutes.

**To run GitHub Actions on your own Mac, download the runner agent from your repository's Settings, register it with labels, install it as a launchd service, and point `runs-on` at those labels.** Self-hosted runners are free to use with Actions; you pay for the Mac instead ([About self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners)). GitHub-hosted macOS bills **$0.062 per minute** on the standard 3- or 4-core image ([About billing for GitHub Actions](https://docs.github.com/en/billing/managing-billing-for-your-products/managing-billing-for-github-actions/about-billing-for-github-actions)), so a flat monthly Mac wins once your builds pass the break-even in the last section.

## What do I need before I install the runner?

You need admin rights on the repository, a Mac with SSH or remote desktop access, and an Xcode installed at a versioned path.

| Requirement | Detail |
|---|---|
| Mac you can log in to | SSH or remote desktop; the commands below assume a terminal on the Mac |
| GitHub permissions | Admin on the target repository (or the organization, for org-level runners) |
| Registration token | Settings → Actions → Runners → New self-hosted runner (tokens expire within the hour) |
| Xcode | Installed at a versioned path, for example `/Applications/Xcode_16.2.app` |
| Homebrew and CocoaPods | Installed ahead of time so jobs do not trigger interactive installs |

Copy the download URL and token from the "New self-hosted runner" screen. The versioned URL changes with each runner release, so do not hard-code it.

## How do I install and register the runner?

Open a terminal on the Mac and run these commands, substituting the values GitHub shows you. The package below is the Apple silicon build; on an Intel Mac VM, use the `osx-x64` package that the same GitHub screen offers.

```bash
mkdir -p ~/actions-runner && cd ~/actions-runner

# GitHub's dialog shows the exact versioned URL — paste it here
curl -o actions-runner-osx-arm64.tar.gz -L \
  "https://github.com/actions/runner/releases/download/vX.Y.Z/actions-runner-osx-arm64-X.Y.Z.tar.gz"
tar xzf ./actions-runner-osx-arm64.tar.gz

# Configure with your org/repo URL and the token from the dialog
./config.sh \
  --url "https://github.com/YOUR_ORG/YOUR_REPO" \
  --token "YOUR_REGISTRATION_TOKEN" \
  --name "figment-mac-01" \
  --labels "self-hosted,macOS,figment-mac,ios-ci" \
  --work "_work" \
  --unattended

# Install as a persistent launchd service and start it
./svc.sh install
./svc.sh start
```

The runner should show **Idle** in Settings → Actions → Runners shortly after. The `--labels` flag lets workflows target this machine. Keep `self-hosted` and `macOS` as the standard pair, then add project labels (`figment-mac`, `ios-ci`) so you can route job types to specific hosts later.

## What does the workflow file look like?

Save this as `.github/workflows/ios.yml` and replace the capitalized placeholders with your workspace and scheme. It targets the labeled runner, pins Xcode, caches Pods and DerivedData, and exits non-zero on a build failure. It is an illustrative example, not a benchmarked run.

```yaml
name: iOS CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build-and-test:
    # Only lands on your registered Figment Mac, never GitHub-hosted
    runs-on: [self-hosted, macOS, figment-mac]

    env:
      XCODE_VERSION: "16.2"            # Pin — bump deliberately, not silently
      DERIVED_DATA: ~/Library/Developer/Xcode/DerivedData/CI

    steps:
      - uses: actions/checkout@v4

      - name: Select Xcode ${{ env.XCODE_VERSION }}
        run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app

      - name: Restore CocoaPods cache
        id: pods-cache
        uses: actions/cache@v4
        with:
          path: |
            Pods
            ~/.cocoapods/repos
          key: pods-${{ runner.os }}-${{ hashFiles('**/Podfile.lock') }}
          restore-keys: |
            pods-${{ runner.os }}-

      - name: Install pods
        if: steps.pods-cache.outputs.cache-hit != 'true'
        run: pod install --repo-update

      - name: Restore DerivedData cache
        uses: actions/cache@v4
        with:
          path: ${{ env.DERIVED_DATA }}
          key: derived-${{ runner.os }}-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }}
          restore-keys: |
            derived-${{ runner.os }}-

      - name: Build and test
        run: |
          set -euo pipefail
          xcodebuild test \
            -workspace YOUR_WORKSPACE.xcworkspace \
            -scheme YOUR_SCHEME \
            -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \
            -derivedDataPath "$DERIVED_DATA" \
            -resultBundlePath TestResults.xcresult \
            | xcpretty

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: test-results-${{ github.run_id }}
          path: TestResults.xcresult
```

`set -euo pipefail` on the build step matters. When you pipe to `xcpretty`, bash runs both processes at once, and without `pipefail` the step exits zero even when `xcodebuild` fails.

## What should I cache, and what must stay out of the cache?

Cache dependencies and build intermediates. Never cache credentials. On a persistent Mac the working directory survives between jobs, so DerivedData that missed the Actions cache still sits on disk until something clears it. Use the cache action for portability and to seed fresh workspaces.

| Path | Cache? | Why |
|---|---|---|
| `Pods/` | Yes | Skips a full re-install when `Podfile.lock` has not changed |
| `~/.cocoapods/repos` | Yes | Avoids re-cloning the specs repo |
| DerivedData | Yes | Reuses compiled intermediates |
| Signing certificates / `.p12` | No | Install from an encrypted CI secret into a temporary keychain each run, then delete |
| Provisioning profiles | No | Deliver as files through the CI secret store; they are not exported from Keychain |
| `.env` files | No | Never write the shell environment to a plaintext file, because it can contain keys. Restore each needed value from your CI secret manager |

A persistent disk or CI cache is not a backup. Figment does not back up your Mac, so keep your source and release artifacts in your own repository or artifact store.

If you restrict network access, update allowlists only on infrastructure you control, such as your artifact store, package proxy or CI service. Do not assume fixed IP ranges for third-party developer services.

## How do I keep a self-hosted runner safe?

Use private repositories only. GitHub's guidance treats self-hosted runners as unsuitable for public repositories because anyone who can open a pull request can run code on your host ([Security hardening for self-hosted runners](https://docs.github.com/en/actions/reference/security/secure-use#hardening-for-self-hosted-runners)). The practical controls:

- **Private repos only.** If you must use self-hosted on a public repo, use ephemeral just-in-time runners that handle one job and remove themselves.
- **Dedicated non-admin user.** Create a macOS account for the runner. Keep its login keychain free of sensitive keys; secrets arrive per job and leave with the job.
- **Rotate signing certificates and API tokens on a schedule.** Do not wait for expiry.
- **Concurrency limits.** `concurrency: group: ${{ github.ref }}` cancels in-flight runs on new pushes, which shortens the exposure window on long jobs.

## At what build volume does a flat-rate Mac beat hosted minutes?

For a Figment Apple Silicon Mac VM, the break-even is about 629 build-minutes a month: $39 ÷ $0.062 = 629.0 minutes, or about 31 twenty-minute builds. For the Dedicated M4 Pro 48 GB it is about 5,629 minutes: $349 ÷ $0.062 = 5,629.0.

| Monthly build volume | GitHub-hosted macOS ($0.062/min) | Figment Apple Silicon VM ($39/month) | Figment Dedicated M4 Pro ($349/month) |
|---|---|---|---|
| 500 min (25 × 20 min) | $31.00 | $39 | $349 |
| **About 629 min** | **About $39** | **$39** | $349 |
| 1,000 min (50 × 20 min) | $62.00 | $39 | $349 |
| 2,500 min (125 × 20 min) | $155.00 | $39 | $349 |
| 5,000 min (250 × 20 min) | $310.00 | $39 | $349 |
| **About 5,629 min** | **About $349** | $39 | **$349** |

Check: 500 × $0.062 = $31; 2,500 × $0.062 = $155; 5,000 × $0.062 = $310. A 20-minute build run 100 times a month is 2,000 minutes, or $124 hosted against $39 flat.

This compares monthly cost at a given volume, not identical hardware. The VM has 4 shared vCPUs, 4GB RAM and 65GB of SSD, and one runner processes jobs one after another. The Dedicated M4 Pro is a whole Mac with an M4 Pro chip, 48GB RAM and a 512GB SSD, which suits parallel runners or heavy builds. Below the break-even, staying on hosted runners costs less and means no runner upkeep. Hosted runners also start every run from a cold toolchain, while a persistent Mac keeps your Pods and DerivedData.

## Which Figment Mac plan fits a runner?

Use the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($0.40 an hour, $6 a day, $39 a month) for a single runner on current Xcode. Use the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) ($349 a month, or $299 a month on a 12-month term) when you want several jobs at once or heavy builds. The [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month) runs macOS Sequoia, so choose it only when Xcode 26.3 or earlier is enough, and it cannot run arm64-only binaries or visionOS. Figment runs the Mac and network layer; you manage the runner, your CI configuration and your GitHub account. We do not offer managed CI.

Before you buy, check the macOS version shown on the plan against Apple's Xcode requirements table.

**Related guides:**
- [Fastlane Match code-signing in CI on Mac](/blog/mac-fastlane-match-ci-codesigning)
- [Parallel Xcode schemes to cut CI build time](/blog/mac-xcode-parallel-scheme-build)
- [Remote Xcode setup on Windows](/blog/mac-xcode-on-windows-remote-setup)
