Home/Guides/Install fastlane and use match to keep signing certificates in a private repo

Install fastlane and use match to keep signing certificates in a private repo

Updated · airankrush

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

  1. 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 fastlane

    The officially preferred method is Bundler: put gem "fastlane" in the Gemfile in the project's top-level directory and run it with bundle 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.

  2. 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-8

    Then run fastlane init in the project directory and follow the prompts to generate the fastlane directory and Fastfile.

  3. 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.

  4. Initialize match

    Create an empty private repository first, then:

    fastlane match init

    Choose the storage mode and enter the repository URL; this generates a Matchfile. Next, generate and store the signing material:

    fastlane match development
    fastlane match appstore

    The 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.

  5. Retrieve read-only on new machines and CI

    fastlane match appstore --readonly

    The 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.

  6. Add one setup_ci line on CI

    According to the setup_ci documentation, calling it at the start of the Fastfile creates 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.

  7. Two things not to do

    First, do not run fastlane match nuke casually. 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_PASSWORD from 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.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All guides