Schedule a daily Fastlane lane that reads each profile's expirationDate from the App Store Connect API, and call match(force: true) only when a profile falls inside a 14 day window. Run this preflight on any Mac that has your Fastlane toolchain, and keep renewal out of the release build itself.
Why do expired provisioning profiles break CI mid sprint?
An expired profile makes the same job that passed yesterday fail today, with an error that looks like a configuration problem. A provisioning profile is a binary blob signed by Apple. It carries your bundle ID, the certificates permitted to sign it, the devices allowed (for development profiles) and an expiry date. App Store distribution profiles typically last twelve months. When Match fetches signing assets, codesign refuses an expired profile with a message that often looks like this:
error: No profile for team '...' matching 'match AppStore com.example.MyApp' found
That message sends engineers hunting for missing entitlements or broken keychains. The cause is a date that passed overnight, and one API call shows it days in advance. The fix is to detect and renew in a scheduled job, not from the release build.
How do I read profile expiry from App Store Connect?
Call /v1/profiles. Each record's attributes.expirationDate is an ISO 8601 timestamp. Confirm the exact field shape against the version your Fastlane build links before you rely on the example below:
curl -s \
-H "Authorization: Bearer $ASC_JWT_TOKEN" \
"https://api.appstoreconnect.apple.com/v1/profiles?filter%5BprofileType%5D=IOS_APP_STORE&limit=200" \
| jq -r '.data[] | [.attributes.name, .attributes.expirationDate] | @tsv'
Inside Fastlane you can skip the raw HTTP and use Spaceship::ConnectAPI, which ships with Fastlane and uses the same API key. The Fastlane match documentation covers force: true and renew_expired_certs: true; both work with App Store Connect API key authentication.
What renewal window should I use?
Use 14 days. That is long enough that a Friday failure can wait until Monday and a cross-timezone team can see the alert, and short enough that profiles are not churned monthly. Shorter windows (3 to 5 days) regularly straddle a weekend or a public holiday. Make the threshold an environment variable so individual pipelines can tune it.
What does the check_profiles lane look like?
It reads the API key path from the CI secret manager (no literal secrets in shell history, no whole environment written to disk), lists profiles through Spaceship, renews only those inside the window, and optionally posts to Slack.
# Fastfile
require 'date'
lane :check_profiles do
key_id = ENV.fetch("ASC_KEY_ID")
issuer_id = ENV.fetch("ASC_ISSUER_ID")
key_path = ENV.fetch("ASC_KEY_PATH") # written by the CI secret manager
api_key = app_store_connect_api_key(
key_id: key_id,
issuer_id: issuer_id,
key_filepath: key_path,
duration: 1200,
in_house: false
)
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.create(
key_id: key_id,
issuer_id: issuer_id,
filepath: key_path
)
threshold = Integer(ENV.fetch("PROFILE_EXPIRY_DAYS", "14"))
today = Date.today
needs_renew = false
Spaceship::ConnectAPI::Profile.all(limit: 200).each do |profile|
expiry = Date.parse(profile.expiration_date)
days_left = (expiry - today).to_i
state = days_left < threshold ? "EXPIRING" : "OK"
UI.message "#{state} #{profile.name}: #{days_left}d (expires #{expiry})"
needs_renew = true if days_left < threshold
end
unless needs_renew
UI.success "All profiles have >= #{threshold} days remaining."
next
end
UI.important "Renewing expiring profiles with match(force: true)"
match(
type: "appstore",
force: true,
renew_expired_certs: true,
api_key: api_key,
readonly: false
)
next unless (webhook = ENV["SLACK_WEBHOOK_URL"])
slack(
message: "Provisioning profiles renewed (threshold #{threshold}d)",
channel: ENV.fetch("SLACK_CHANNEL", "#ios-builds"),
slack_url: webhook,
success: true
)
end
This lane is an untested example. Run it once interactively against your installed Fastlane to confirm the Spaceship method names in your version and that profile.expiration_date returns the value you expect before you enable the schedule.
match(force: true) regenerates the profile on every run. It is meant for the renewal case, not for every build, so keep it inside check_profiles and never call it from commit-triggered jobs.
How do I schedule the lane and write back to Git?
Match commits the refreshed profile to the cert repo automatically. Give the runner Git write access with a deploy key stored as a CI secret, and set the identity once:
git config --global user.email "ci-bot@example.com"
git config --global user.name "CI Bot"
Schedule the lane on its own, independent of commit-triggered builds, so it runs on quiet days:
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
jobs:
preflight:
runs-on: [self-hosted, macOS, arm64]
steps:
- uses: actions/checkout@v4
- name: Rotate expiring profiles
env:
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_KEY_PATH: ${{ runner.temp }}/asc_key.p8
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
umask 077
printf '%s' "${{ secrets.ASC_KEY_CONTENT }}" > "$ASC_KEY_PATH"
trap 'rm -f "$ASC_KEY_PATH"' EXIT
bundle exec fastlane check_profiles
umask 077 runs before the secret is written so the .p8 file is not world readable, and the trap removes it on exit. Do not dump the whole environment to a file, and do not import the profile into a Keychain. Profiles are files on disk; only signing certificates need Keychain handling (an encrypted .p12 with its private key).
Can the Intel Mac VM host the scheduled profile preflight?
The preflight is light: it talks to Apple's API and runs Fastlane. An Intel Mac VM ($0.15 an hour, $2 a day, $25 a month) can host the scheduled lane when you need Xcode 26.3 or earlier (per Apple's porting guidance). It runs macOS Sequoia and cannot run arm64-only binaries. For production iOS builds on current Xcode, use an Apple Silicon Mac VM ($39 a month, $6 a day), or a Dedicated M4 Pro 48 GB ($349 a month) for heavy archives. Check the macOS version shown before purchase against Apple's Xcode table.
For scale, CloudMac lists a Mac mini M4, 16GB, 256GB at $99.99 a month, and the CloudMac homepage advertises a $999 a year option, about $83.25 a month. Twelve months of the Apple Silicon Mac VM is 12 × $39 = $468, which is $531 less than $999 and $731.88 less than 12 × $99.99 = $1,199.88. The hardware differs: the VM has 4 shared vCPUs, 4GB RAM and a 65GB SSD. Figment does not offer managed CI, so you own the check_profiles rollout, your Fastlane setup and your Apple account.
Related guides: