Move the team ID, certificate password, App Store Connect API key, issuer ID and provisioning profile UUID out of your scripts and into CI secrets, inject them as environment variables at build time, then grep the raw log and artifacts to confirm nothing leaked. Hardcoded credentials in a CI script are one commit away from a public git history. This page covers GitHub Actions; the same pattern applies to other CI systems.
Where do iOS CI secrets usually leak from?
From scripts and debug leftovers. Audit your pipeline for these exposure points before you change anything:
xcodebuild ... DEVELOPMENT_TEAM=XXXXXXXXXXin a shell script committed to the repo.security import cert.p12 -P "hardcoded_password"with the password on the command line.fastlane deliverpointing to an API key file inside the repo.- Leftover
echo "$MATCH_PASSWORD"from a debug session. - A diagnostics step that runs
envorprintenvinto an artifact.
Never dump the whole environment to a file. Transfer the required variable names to the new system separately and populate the values from your secret manager at runtime. A plaintext env snapshot captures every secret the shell can see.
How big can a GitHub Actions secret be, and do forks get them?
A secret can be up to 48 KB, and forks do not get them. GitHub Actions supports repository, environment, and organization secrets, and documents a workaround pattern for larger payloads (GitHub Actions: using secrets). A .p12 certificate usually fits once base64-encoded. If it does not, store the decryption passphrase as the secret and keep the encrypted blob in the repo.
Two behaviors matter for pipeline design:
- Secrets other than
GITHUB_TOKENare not passed to runners triggered from forked repositories. If you accept external PRs, do not rely on signing succeeding on fork-triggered workflows. - GitHub redacts registered secret values from job output. Values derived from a secret (for example, the decoded binary) are not automatically masked. Use
::add-mask::VALUEto register derived sensitive strings.
Which secrets do I need, and how do I inject them?
Six, one per value below. Keep the base64 form as the registered secret, so GitHub redacts that string from logs even if a step echoes it by mistake.
| Secret | Storage type | Format | Injection | Log check |
|---|---|---|---|---|
APPLE_TEAM_ID | Env secret | 10-char string | env: on the build step | grep log for the 10-char value |
CERT_P12_PASSWORD | Env secret | String | env: then -P "$CERT_P12_PASSWORD" | grep log for the password |
APP_STORE_CONNECT_API_KEY_BASE64 | Env secret | Base64 of .p8 | Decode to a temp file at runtime | grep log for -----BEGIN |
APP_STORE_CONNECT_ISSUER_ID | Env secret | UUID | env: passed to Fastlane | grep log for the UUID |
PROVISIONING_PROFILE_UUID | Env secret | UUID | env: referenced in Fastfile | grep log for the UUID |
CERT_P12_BASE64 | Env secret | Base64 of .p12 | Decode to temp file; security import | confirm no -----BEGIN CERTIFICATE in log |
How do I encode, decode and clean up signing files?
Encode once locally and store the output as a secret:
base64 -i AuthKey_XXXXXXXXXX.p8 | tr -d '\n'
base64 -i Certificates.p12 | tr -d '\n'
Decode in the job with a restrictive umask so the files are never world-readable, and clean up on failure:
- name: Decode signing assets
env:
ASC_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
CERT_P12_BASE64: ${{ secrets.CERT_P12_BASE64 }}
run: |
set -euo pipefail
umask 077
WORKDIR="$(mktemp -d)"
echo "WORKDIR=$WORKDIR" >> "$GITHUB_ENV"
printf '%s' "$ASC_API_KEY_BASE64" | base64 --decode > "$WORKDIR/asc_api_key.p8"
printf '%s' "$CERT_P12_BASE64" | base64 --decode > "$WORKDIR/Certificates.p12"
- name: Import certificate
env:
CERT_P12_PASSWORD: ${{ secrets.CERT_P12_PASSWORD }}
run: |
set -euo pipefail
ORIG_LIST=$(security list-keychains -d user | tr -d '"')
security create-keychain -p "" build.keychain
security unlock-keychain -p "" build.keychain
security set-keychain-settings -lut 3600 build.keychain
security import "$WORKDIR/Certificates.p12" \
-k build.keychain \
-P "$CERT_P12_PASSWORD" \
-T /usr/bin/codesign
security list-keychains -d user -s build.keychain $ORIG_LIST
- name: Clean up
if: always()
run: rm -rf "${WORKDIR:-}"
Two details. security list-keychains -s replaces the search list, so the snippet preserves the previous entries and appends build.keychain. if: always() runs after a normal step failure, but it cannot guarantee cleanup after a runner machine is killed, so never store long-lived secrets on the runner disk.
Provisioning profiles are not imported into the Keychain. Write the .mobileprovision file to ~/Library/MobileDevice/Provisioning Profiles/ under its UUID and let xcodebuild or Fastlane match pick it up.
How do I pass secrets to Fastlane and xcodebuild?
Fastlane reads most inputs from environment variables, but the exact name depends on the action. Run fastlane action <name> to list parameters and their env var equivalents for your installed version (Fastlane key management):
fastlane action app_store_connect_api_key # key id, issuer id, key filepath
fastlane action match # MATCH_PASSWORD, MATCH_GIT_URL, ...
fastlane action pilot # TestFlight upload inputs
Pass secrets to xcodebuild as build settings, never as literals on the shell command line:
- name: Archive
env:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: |
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" \
-configuration Release -destination 'generic/platform=iOS' \
DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
-archivePath "$WORKDIR/App.xcarchive" archive
Replace $WORKSPACE and $SCHEME with the real values from your project (xcodebuild -list prints them). Do not commit a .env file with real secrets, even with .gitignore. A force-push or a mis-scoped ignore pattern is the usual reason production keys end up on GitHub.
How do I check that masking worked?
After the first green run, spot-check masking with a disposable step, then delete it:
- name: One-shot masking check (delete after use)
env:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: echo "team=$APPLE_TEAM_ID" # expect: team=***
Download the raw log and grep for the real values from a trusted machine:
grep -F "$KNOWN_TEAM_ID" full-build.log
grep -E "BEGIN (PRIVATE KEY|CERTIFICATE|EC PRIVATE KEY)" full-build.log
Also scan .xcresult bundles, test reports, and .ipa artifacts. A debugging env or printenv step is the most common source of accidental secret exposure in CI.
How do I rotate a secret without breaking running builds?
Add the new value under a parallel name:
- Add the new value as
MATCH_PASSWORD_V2. - Point the workflow at the new name on a feature branch and confirm a green build.
- Merge to default.
- Delete the old secret once no in-flight runs reference it.
Updating a secret value in place while jobs are running can race with step startup and surface as an empty string on some platforms.
Do the secrets pipeline steps run on either Mac VM?
Every step above needs macOS (security, codesign, xcodebuild, Fastlane signing actions), so choose by Xcode version. Use the Apple Silicon Mac VM ($39 a month, $6 a day) for current Xcode, including Xcode 26.4 and later. Use the Intel Mac VM ($25 a month) only if Xcode 26.3 or earlier on macOS Sequoia is enough, since it cannot run arm64-only binaries or visionOS. A Dedicated M4 Pro 48 GB ($349 a month) suits parallel or heavy builds. Figment does not manage your CI or your secrets. You install the runner and keep signing material in your own secret manager.
Worked cost for a solo iOS CI on the Intel VM: 12 × $25 = $300 a year, plus a free GitHub Actions self-hosted runner install. On the Apple Silicon VM: 12 × $39 = $468 a year. For comparison, CloudMac's published $999/year M4/16 GB/256 GB offer (cloudmac.org/pricing) works out to $83.25 a month, but it is a different hardware class from a shared 4GB VM. Tax and any fees apply as stated in each provider's offer.
Related guides: