$npx -y skills add greenstevester/fastlane-skill --skill matchSet up Match for iOS code signing certificate management
| 1 | ## Code Signing with Match |
| 2 | |
| 3 | Set up Fastlane Match to manage iOS code signing certificates and provisioning profiles in a shared Git repository. |
| 4 | |
| 5 | ### Pre-flight Checks |
| 6 | - Fastlane installed: !`fastlane --version 2>/dev/null | grep "fastlane " | head -1 || echo "✗ Not installed - run: brew install fastlane"` |
| 7 | - Fastfile exists: !`ls fastlane/Fastfile 2>/dev/null && echo "✓ Found" || echo "✗ Not found - run /setup-fastlane first"` |
| 8 | - Existing Matchfile: !`ls fastlane/Matchfile 2>/dev/null && echo "✓ Already configured" || echo "○ Not configured yet"` |
| 9 | - Git available: !`git --version 2>/dev/null | head -1 || echo "✗ Git not installed"` |
| 10 | |
| 11 | ### Arguments: ${ARGUMENTS:-setup} |
| 12 | |
| 13 | --- |
| 14 | |
| 15 | ## What is Match? |
| 16 | |
| 17 | Match stores your iOS certificates and provisioning profiles in a **private Git repository**, encrypted with a passphrase. Benefits: |
| 18 | |
| 19 | - **Team sharing**: Everyone uses the same certificates (no more "works on my machine") |
| 20 | - **CI/CD ready**: Clone the repo in your pipeline, no manual cert management |
| 21 | - **Revoke protection**: Prevents accidental certificate revocation |
| 22 | - **Audit trail**: Git history shows who changed what and when |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Step 1: Create a Private Git Repository |
| 27 | |
| 28 | Create a **private** repository to store your encrypted certificates: |
| 29 | |
| 30 | ```bash |
| 31 | # GitHub CLI (recommended) |
| 32 | gh repo create certificates --private |
| 33 | |
| 34 | # Or manually at github.com/new (select Private) |
| 35 | ``` |
| 36 | |
| 37 | **Repository naming conventions:** |
| 38 | - `certificates` or `ios-certificates` |
| 39 | - `fastlane-certs` |
| 40 | - `{company}-signing` |
| 41 | |
| 42 | > **Security**: This repo will contain encrypted certificates. Keep it private and limit access to team members who need to build the app. |
| 43 | |
| 44 | --- |
| 45 | |
| 46 | ## Step 2: Initialize Match |
| 47 | |
| 48 | Run match init to create your Matchfile: |
| 49 | |
| 50 | ```bash |
| 51 | fastlane match init |
| 52 | ``` |
| 53 | |
| 54 | When prompted: |
| 55 | 1. **Storage mode**: Select `git` |
| 56 | 2. **Git URL**: Enter your private repo URL (e.g., `git@github.com:yourorg/certificates.git`) |
| 57 | |
| 58 | This creates `fastlane/Matchfile`: |
| 59 | |
| 60 | ```ruby |
| 61 | git_url("git@github.com:yourorg/certificates.git") |
| 62 | |
| 63 | storage_mode("git") |
| 64 | |
| 65 | type("development") # Default type, can be overridden per-lane |
| 66 | |
| 67 | # app_identifier(["com.yourcompany.app"]) # Optional: limit to specific apps |
| 68 | # username("user@example.com") # Optional: Apple ID |
| 69 | ``` |
| 70 | |
| 71 | --- |
| 72 | |
| 73 | ## Step 3: Generate Certificates |
| 74 | |
| 75 | Generate certificates for each distribution type: |
| 76 | |
| 77 | ### Development (for debugging on devices) |
| 78 | ```bash |
| 79 | fastlane match development |
| 80 | ``` |
| 81 | |
| 82 | ### App Store (for TestFlight and App Store) |
| 83 | ```bash |
| 84 | fastlane match appstore |
| 85 | ``` |
| 86 | |
| 87 | ### Ad Hoc (for direct device distribution) |
| 88 | ```bash |
| 89 | fastlane match adhoc |
| 90 | ``` |
| 91 | |
| 92 | **First run prompts:** |
| 93 | 1. **Apple ID**: Your Apple Developer account email |
| 94 | 2. **Passphrase**: Create a strong passphrase to encrypt certificates (save this securely!) |
| 95 | |
| 96 | > **Important**: Save the passphrase in a password manager. You'll need it for CI/CD and new team members. |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## Step 4: Integrate with Fastfile |
| 101 | |
| 102 | Update your lanes to use Match before building: |
| 103 | |
| 104 | ```ruby |
| 105 | default_platform(:ios) |
| 106 | |
| 107 | platform :ios do |
| 108 | desc "Sync all certificates" |
| 109 | lane :sync_signing do |
| 110 | match(type: "development") |
| 111 | match(type: "appstore") |
| 112 | end |
| 113 | |
| 114 | desc "Install signing assets on CI (read-only)" |
| 115 | lane :certificates do |
| 116 | setup_ci # temp keychain on CI; no-op locally |
| 117 | match(type: "appstore", readonly: true) |
| 118 | end |
| 119 | |
| 120 | desc "Build for TestFlight" |
| 121 | lane :beta do |options| |
| 122 | setup_ci # temp keychain on CI; no-op locally |
| 123 | match(type: "appstore", readonly: true) |
| 124 | increment_build_number unless options[:skip_build_increment] |
| 125 | gym(scheme: "YourApp", export_method: "app-store") |
| 126 | pilot(skip_waiting_for_build_processing: true) |
| 127 | end |
| 128 | |
| 129 | desc "Build for App Store" |
| 130 | lane :release do |
| 131 | setup_ci # temp keychain on CI; no-op locally |
| 132 | match(type: "appstore", readonly: true) |
| 133 | increment_build_number |
| 134 | gym(scheme: "YourApp", export_method: "app-store") |
| 135 | deliver(submit_for_review: false, force: true) |
| 136 | end |
| 137 | end |
| 138 | ``` |
| 139 | |
| 140 | **Key pattern**: Use `readonly: true` in build lanes to prevent accidental certificate regeneration. |
| 141 | |
| 142 | **CI keychain**: `setup_ci` creates a temporary keychain on CI runners (and is a no-op locally) so `match` can import certs without keychain-permission errors. Call it before `match` in any lane that runs on CI. |
| 143 | |
| 144 | --- |
| 145 | |
| 146 | ## Step 5: Onboard Team Members |
| 147 | |
| 148 | New team members run: |
| 149 | |
| 150 | ```bash |
| 151 | # Clone and decrypt existing certificates (readonly) |
| 152 | fastlane match development --readonly |
| 153 | fastlane match appstore --readonly |
| 154 | ``` |
| 155 | |
| 156 | They'll need: |
| 157 | 1. Access to the private certificates repository |
| 158 | 2. The Match passphrase |
| 159 | 3. Apple Developer team membership |
| 160 | |
| 161 | **Readonly mode** ensures they can't accidentally revoke or regenerate certificates. |
| 162 | |
| 163 | --- |
| 164 | |
| 165 | ## Step 6: CI/CD Setup |
| 166 | |
| 167 | Set these environment variables in your CI/CD system: |
| 168 | |
| 169 | ```bash |
| 170 | # Required |
| 171 | MATCH |