Sooner or later every iOS project wants “push a commit, get a TestFlight build”. Hosted CI can do it with macOS machines, but there are two familiar pain points:
- Per-minute billing — and macOS minutes cost far more than Linux minutes. Bigger projects and more commits mean a bill that grows fast.
- A clean machine every time — CocoaPods and Swift Package dependencies, DerivedData caches: all downloaded and rebuilt from scratch, so a single build can easily take 10–20 minutes.
If you have a Mac that’s on 24/7 — your own or a rented one — you can register it as a self-hosted GitHub Actions runner. Dependencies and caches stay on the machine, so every build after the first is much faster, and the cost is fixed.
Prepare the Mac
- Xcode — the same version you use locally. Open it once after installing to accept the licence and install the platform components you need.
- Homebrew and your usual tools:
brew install fastlane
brew install cocoapods # only if your project uses CocoaPods
- Check the command line can see Xcode:
xcodebuild -version.
Step 1: Register the runner
- In your GitHub repository go to Settings → Actions → Runners → New self-hosted runner.
- Choose macOS and ARM64 (Apple silicon).
- GitHub shows a set of commands (download, extract,
./config.sh --url ... --token ...). Run them exactly as shown in Terminal on the Mac. The token expires — if it does, reopen the page for a new one. - Add a label such as
iosduring setup so workflows can target this runner.
Run ./run.sh in the foreground first. When GitHub shows the runner as Idle, it’s connected.
Step 2: Keep it running
A foreground runner stops when you close Terminal. Install it as a service from the runner directory:
./svc.sh install
./svc.sh start
This installs a LaunchAgent for the current user, which starts when that user logs in. So the Mac should log in to this user automatically at startup and never sleep — otherwise the runner goes offline after a restart or a nap.
Step 3: Write the workflow
Create .github/workflows/ios.yml:
name: iOS build
on:
push:
branches: [main]
jobs:
build:
runs-on: [self-hosted, macOS, ARM64]
steps:
- uses: actions/checkout@v4
- name: Build & upload to TestFlight
run: fastlane beta
env:
APP_STORE_CONNECT_API_KEY_JSON: ${{ secrets.ASC_KEY_JSON }}
fastlane beta is a lane you define in fastlane/Fastfile — typically: fetch certificates → build_app → upload_to_testflight.
Code signing: where most setups get stuck
- Use an App Store Connect API key, not an Apple ID with two-factor authentication — there’s nobody around to type the code in CI. Create one in App Store Connect → Users and Access → Integrations and store it in GitHub Secrets.
- Certificates and provisioning profiles: for teams,
fastlane matchkeeps them in one place; for a solo project you can simply install the certificate in this Mac’s keychain. - Locked keychain: when the runner runs as a service, the keychain may be locked and
codesignhangs or fails. Unlock it at the start of the build withsecurity unlock-keychain, or create a dedicated CI keychain (fastlane’ssetup_ci/create_keychaincan do this for you).
Security: private repositories only
GitHub’s own advice: don’t use self-hosted runners with public repositories. Anyone can open a pull request on a public repo, and the workflow would run their code on your machine.
Also:
- Workflows get every permission of the user the runner runs as. Keep only the certificates and keys this machine actually needs.
- Clean out DerivedData and old build products regularly — a smaller drive (such as 256GB) fills up fast with a few projects and Xcode versions.
With Tokyo Mac
A Tokyo Mac machine is a dedicated Mac mini (current configurations are listed in the store) in Tokyo, with sleep and screen lock turned off and automatic login to your account — exactly what an always-on runner needs. Tick Homebrew when you set up your account, then follow the steps above to install Xcode and register the runner.
Want to check build speed and the network first? Start with a 24-hour trial.
Related: How to build and publish an iOS app without owning a Mac · How to connect to a remote Mac