What this guide covers
When you finish, any new Mac can retrieve the signing material with a single command. You need: Xcode and Homebrew installed, a private Git repository (or object storage) that only you can access, and a developer account.
Steps
Install fastlane
Following the official fastlane setup page, first make sure the Command Line Tools are installed (
xcode-select --install), then pick a method. Homebrew is the most straightforward:brew install fastlaneThe officially preferred method is Bundler: put
gem "fastlane"in theGemfilein the project's top-level directory and run it withbundle exec fastlane, so everyone on the team and every machine uses the same version. The official page notes that installing with the system Ruby is not recommended.Set the locale environment variables
The official page requires adding the two lines below to your shell configuration; otherwise uploads and builds may have problems:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8Then run
fastlane initin the project directory and follow the prompts to generate thefastlanedirectory andFastfile.Understand the problem match solves
According to the match documentation, it creates the required certificates and provisioning profiles and stores them in a separate private Git repository, Google Cloud or Amazon S3; with Git storage the contents are encrypted.
What this means for a rented machine: the "original" of the signing material is no longer only in this Mac's keychain. Whether the machine is reclaimed or you move to another one, the new machine simply retrieves it from your storage.
Initialize match
Create an empty private repository first, then:
fastlane match initChoose the storage mode and enter the repository URL; this generates a
Matchfile. Next, generate and store the signing material:fastlane match development fastlane match appstoreThe first run asks you to set an encryption passphrase. Store it in your own password manager; if the passphrase is lost, the contents of the repository cannot be decrypted.
Retrieve read-only on new machines and CI
fastlane match appstore --readonlyThe documentation recommends always using read-only mode on CI to make sure it does not create new certificates or provisioning profiles. The encryption passphrase is passed in through an environment variable named
MATCH_PASSWORD; keep it in your CI platform's secret variables, not in the repository.The parameter notes in the documentation also mention that the first time certificates are accessed on a new Mac, the keychain password may be needed; for the login keychain, that is your macOS account password.
Add one setup_ci line on CI
According to the setup_ci documentation, calling it at the start of the
Fastfilecreates a temporary keychain for match to use and switches match to read-only mode. The signing material then stays out of the login keychain, and things are cleaner between jobs.Two things not to do
First, do not run
fastlane match nukecasually. The documentation says it revokes all certificates and provisioning profiles for the given environment. Apps already on the App Store and in TestFlight stay available, but Ad Hoc and enterprise distribution builds stop working.Second, do not let this machine hold more than read access to the repository. A read-only deploy key is enough (the one run that generates the certificates can be done in an environment you trust). Before the rental ends, revoke that key and clear
MATCH_PASSWORDfrom the machine.
FAQ
I already created a distribution certificate by hand. Can I still use match?
Yes, but each team can have only one distribution certificate of each type, so match has to take over the existing one or create a new one after it is revoked. Go by the official match documentation for how to import. Before you start, confirm that the existing certificate's private key is in your hands.
Where should the match repository live?
In a private repository or object storage that only you or your team can access. What it stores is encrypted signing material, and it should still be treated as sensitive data.
fastlane asks for a verification code when signing in to my Apple Account. What do I do?
Interactive sign-in needs you there for the code. For unattended runs, use an App Store Connect API key instead; according to the fastlane documentation, match, pilot, deliver and others all support key authentication.
Will fastlane installed with Homebrew conflict with the Bundler one?
The two can coexist. When the project has a Gemfile, always use bundle exec fastlane so the version matches the team's.
Related
- How to create iOS certificates and profiles and back up the private key as .p12
- How to upload iOS builds with an App Store Connect API key, with no 2FA prompts
- Code signing hangs on a CI Mac: unlock the keychain or use a dedicated one
- How do I sign an iOS app and upload it to the App Store from a remote Mac?
- Rented Mac mini as an always-on build machine for small teams? Count your build minutes first
Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support