Keep certificates and profiles in one private, encrypted match repo, then in CI create a temporary keychain, run match with readonly: true, and archive with gym. Rotate certificates only from a developer machine. This page gives a working Matchfile, a Fastfile lane, the four secrets, and a rotation lane that never races CI.
Why does code signing fail on a headless CI Mac?
Because there is no GUI session to answer a prompt. Every iOS distribution build needs a valid distribution certificate plus a matching provisioning profile (Apple: Distributing your app for beta testing and releases). On a developer laptop Xcode asks for Apple ID credentials, downloads the cert, and stores the private key in login.keychain. On a headless CI Mac a security prompt silently blocks codesign, the job hangs, and the build times out with a log that says nothing useful.
A second problem compounds it. When four engineers each manage their own certificates, they generate four separate ones for the same team. Apple caps distribution certificates per account, so teams eventually hit the limit and revoke each other's certs by accident.
Fastlane Match solves both. It keeps one encrypted set of certificates and profiles in shared storage, and every machine, whether a developer workstation or a headless CI runner, decrypts and installs the same set with no GUI interaction.
Where does match store certificates?
In a private Git repository, Google Cloud Storage, or Amazon S3, per the match documentation. With Git storage, certificates and private keys are encrypted with OpenSSL using a passphrase before they are committed. The passphrase travels separately as the MATCH_PASSWORD environment variable.
| File type | Path in storage repo |
|---|---|
Distribution certificate (.cer) | certs/distribution/ |
Certificate private key (.p12, encrypted) | certs/distribution/ |
Provisioning profile (.mobileprovision) | profiles/appstore/ or profiles/adhoc/ |
When match runs in CI it clones the repo, decrypts each file with MATCH_PASSWORD, imports the .p12 into a keychain, and copies profiles into ~/Library/Developer/Xcode/UserData/Provisioning Profiles/ on Xcode 16 and later. The pre-16 path was ~/Library/MobileDevice/Provisioning Profiles/, per the match docs.
Provisioning profiles are plain files copied from the repo. They are never exported from Keychain. Only the certificate's private key (.p12) is imported into the keychain.
How do I create the storage repo and run match init?
Create a private repo, install Fastlane, and run fastlane match init.
- Create a private Git repo on GitHub, GitLab, or your own host. Never make it public, because it contains encrypted private-key material.
- On your Mac (over SSH, remote desktop, or your CI runner's shell), install Fastlane and initialize:
gem install fastlane
cd path/to/your/ios/project
fastlane match init
The prompt asks for the storage type (git) and the private repo URL, and writes fastlane/Matchfile. Edit it so it is explicit:
# fastlane/Matchfile
git_url("https://github.com/YOUR_ORG/YOUR_CERTS_REPO")
git_branch("main")
storage_mode("git")
type("appstore") # default; lanes can override with type: "adhoc"
app_identifier(["com.example.MyApp"])
username("ci-apple-id@example.com")
Then, from a machine that can still authenticate interactively with Apple, generate the first certificate set:
fastlane match appstore
fastlane match adhoc # only if you distribute Ad Hoc builds
Match creates the certificate on Apple's developer portal, encrypts it, and pushes it to the storage repo. Every later CI build fetches that set instead of asking Apple for a new one.
What does the Fastfile lane for CI look like?
Add this lane to fastlane/Fastfile. It sets up a disposable keychain, pulls certs in readonly mode, and archives the IPA.
# fastlane/Fastfile
default_platform(:ios)
platform :ios do
desc "Build a signed App Store IPA on a headless Mac"
lane :build_ipa do
# 1. Disposable keychain so codesign never shows a GUI prompt.
create_keychain(
name: ENV["MATCH_KEYCHAIN_NAME"],
password: ENV["MATCH_KEYCHAIN_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false
)
# 2. Pull certs and profiles — never create new ones from CI.
match(
type: "appstore",
readonly: true,
keychain_name: ENV["MATCH_KEYCHAIN_NAME"],
keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"]
)
# 3. Archive. Use your real workspace and scheme names.
gym(
workspace: "YOUR_WORKSPACE.xcworkspace",
scheme: "YOUR_SCHEME",
configuration: "Release",
export_method: "app-store",
output_directory: "build/",
output_name: "MyApp.ipa",
clean: true
)
end
desc "Revoke and regenerate App Store certs — run from a dev machine"
lane :rotate_certs do
match(
type: "appstore",
force: true
)
end
end
readonly: true is not optional in CI. Without it, a transient fetch failure can make match create a new certificate, which uses an account slot and can invalidate one a teammate still uses. The match docs call this behavior out directly.
This file is an example, not a benchmark. Point workspace and scheme at the real values in your project before you run it. The lane fails fast if either is wrong.
Which secrets does the CI job need?
Four. Never dump the whole environment to a file, because that serializes API tokens next to the keychain password.
| Secret name | Value |
|---|---|
MATCH_PASSWORD | Passphrase chosen when the storage repo was initialized |
MATCH_KEYCHAIN_NAME | A short name, e.g. ci-build.keychain |
MATCH_KEYCHAIN_PASSWORD | A random strong password for the temporary keychain |
MATCH_GIT_BASIC_AUTHORIZATION | Base64 of username:token with read access to the certs repo |
In GitHub Actions, store each as a repository or organization secret and expose them to the step that calls Fastlane:
- name: Build signed IPA
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_KEYCHAIN_NAME: ci-build.keychain
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
run: bundle exec fastlane build_ipa
Secret masking in CI logs applies to the exact secret string. Transformed, trimmed, or base64-decoded substrings can still appear in logs, so never echo a secret and never write env > .env as a debug step.
How do I rotate certificates without breaking pipelines?
Run the rotation lane from a developer machine, never from CI. Apple distribution certificates expire, and sometimes a key leaks and must be revoked out of cycle.
- Run
fastlane rotate_certsfrom a developer machine with Apple portal access. force: truerevokes the old cert, issues a new one, re-signs the existing profiles, and pushes encrypted replacements to the storage repo.- Because every CI job uses
readonly: true, the next pipeline run picks up the new cert automatically. You change no workflow and rotate no secret, becauseMATCH_PASSWORDis unchanged.
If two developers run match without readonly: true at the same time, they can trigger concurrent certificate creation and revoke each other's work. Keep readonly: true everywhere except the one explicit rotation lane.
How do parallel match pipelines change the Mac you need?
Match is storage-agnostic, so pick the Mac by Xcode version and how many pipelines run in parallel.
| Scenario | Figment plan | What you get |
|---|---|---|
| Current Xcode, occasional releases or daily TestFlight builds | Apple Silicon Mac VM, $39 a month or $6 a day | 4 shared vCPUs, 4GB RAM, 65GB SSD |
| Parallel signing pipelines or heavy builds | Dedicated M4 Pro 48 GB, $349 a month | Whole Mac: M4 Pro, 48GB RAM, 512GB SSD |
| Xcode 26.3 or earlier is enough | Intel Mac VM, $25 a month | 4 shared vCPUs, 4GB RAM, 80GB SSD, macOS Sequoia |
Figment does not run your CI. You install the runner, keychain and Fastlane toolchain, and wire the four secrets above into your CI provider. Many Macs or hard delivery dates are quoted on a call. Taxes apply as shown at checkout.
Related guides: