iOS Code Signing, From First Principles
22 minutes read •
This write-up was distilled from a real session: wiring a CI pipeline to ship a ShowCase app (a design-system demo app) to TestFlight, debugged end-to-end with an AI agent. The release build failed with no provisioning profile was found named 'match AppStore com.example.designkit.ShowCase'. A profile was downloaded to “fix” it — and turned out to be the wrong type. Untangling that one error required understanding the entire chain: certificates, App IDs, devices, profiles, the four distribution channels, fastlane match, and where a profile has to physically sit for a build to find it. This document builds every concept from scratch and ends with a reference you can reuse. Prerequisites: you’ve built an iOS app once and know what an .ipa roughly is. Nothing more.
Part 1 — The cast of five
Apple code signing answers one question at install/launch time: "Is this exact app allowed to run on this device, and who vouches for it?" Everything else is bookkeeping that supports that check. There are exactly five primitives. Learn what each one binds and the rest follows.
1. Team / Account
Your Apple Developer Program membership, identified by a Team ID (e.g. ABCDE12345). Everything below is scoped to one team. Two apps in the same team share certificates; two apps in different accounts share nothing.
2. Certificate
Proves who built the app. A public/private key pair where Apple signs your public key. Team-scoped, not app-scoped.
3. App ID
The app's identity — its bundle id (com.example.designkit.ShowCase) plus the capabilities it's allowed to use.
4. Device
A specific iPhone/iPad registered by UDID. Only matters for two of the four profile types. Capped at 100 per device class per year.
5. Provisioning profile
The document that ties the other four together and is signed by Apple. This is the piece everyone finds confusing, because it's the knot — so we build up to it.
The mental model: a certificate says who, an App ID says what, devices say where, and a provisioning profile is Apple's signed statement that this who + what + where combination is permitted.
Part 2 — Certificates: who you are
A signing certificate is a public/private key pair. You generate the pair locally; the private key never leaves your Keychain. You send a Certificate Signing Request (the public half) to Apple, and Apple hands back a certificate — essentially your public key with Apple's signature on it, saying "this key belongs to this team."
When you sign an app, codesign uses the private key to produce a signature over the app bundle. When iOS verifies the app, it checks that signature against the certificate embedded (by reference) in the provisioning profile. No private key → you cannot sign. No matching certificate in the profile → the device rejects the signature.
Two kinds matter:
| Certificate | Purpose | Scope |
|---|---|---|
| Apple Development | Sign debug builds you run from Xcode on your own registered devices. | Per-developer (each dev usually has their own). |
| Apple Distribution | Sign everything you ship: Ad-Hoc, TestFlight, App Store. | One per team, shared. The same distribution cert signs every app in the team. |
Certificates are team-scoped, never app-scoped.
This is why, in our session, the existing Apple Distribution certificate could sign a brand-new app (com.example.designkit.ShowCase) without anything new — as long as the app lived in the same team. A new bundle id does not require a new certificate. (It does require a new profile — see Part 4.)
Practical gotcha: Apple limits the number of distribution certificates per account (historically ~2–3). If every engineer and every CI machine generated their own, you'd exhaust the limit and break each other's signing. That problem is exactly what fastlane match exists to solve.
Part 3 — App IDs & entitlements: what the app is
An App ID registers a bundle id with Apple and records which capabilities it may use (Push Notifications, Associated Domains, Keychain Sharing, App Groups, …). Two forms:
- Explicit:
com.example.designkit.ShowCase— matches exactly one app. Required for capabilities like Push. - Wildcard:
com.example.*— matches a family of apps, but can't carry most capabilities.
Entitlements are the runtime permissions your app actually requests (in an .entitlements file). The rule the OS enforces: the entitlements baked into your signed app must be a subset of what the App ID enables and what the provisioning profile grants. Ask for an entitlement the profile doesn't carry → install fails. This is a common source of "it ran in debug but the release build won't install."
Part 4 — The provisioning profile: the knot
A provisioning profile is a single file (.mobileprovision) that is a CMS-signed property list. "Signed" means Apple has cryptographically endorsed its contents — you can't edit it. Inside, it bundles:
.app with your private key, and copies the profile into the bundle as embedded.mobileprovision.The profile is the contract the device evaluates. It is the only one of the five primitives that travels inside the shipped app.
Two consequences that trip everyone up:
- Profiles are bundle-id-scoped. A profile for
com.example.OtherAppcan never signcom.example.designkit.ShowCase, even in the same team with the same certificate. A new app always needs a new profile. - Profiles expire (typically one year). The cert can be valid while the profile is stale, or vice-versa. "It built last quarter" is not evidence it builds today.
Part 5 — Four profile types, two flags
There are four profile types, and you can tell them apart by just two fields inside the decoded plist: get-task-allow (is the app debuggable?) and ProvisionedDevices (is there a UDID allowlist?).
| Type | get-task-allow | ProvisionedDevices | Signed with | Used for |
|---|---|---|---|---|
| Development | true | yes (your devices) | Apple Development | Xcode run/debug |
| Ad-Hoc | false | yes (allowlist) | Apple Distribution | OTA install to listed devices |
| App Store | false | none | Apple Distribution | TestFlight & App Store |
| Enterprise | false | none, but ProvisionsAllDevices=true | In-House Distribution | Internal distribution (Apple Enterprise Program only) |
The single most useful distinction in practice:
Ad-Hoc and App Store profiles are both signed with the same distribution certificate and both have get-task-allow=false. They differ in one thing: Ad-Hoc has a device allowlist, App Store does not.
That one difference decides everything downstream. A device list means "only these phones." No device list means "this goes through Apple's store infrastructure (TestFlight/App Store), which controls distribution instead." You cannot mix them: an Ad-Hoc profile cannot be uploaded to TestFlight, and an App Store profile cannot sideload onto a random device.
Part 6 — Channels: how a build reaches a human
"How do I get the app onto someone's phone?" has four answers, and each is locked to a profile type. Choosing the channel is choosing the profile.
Development
Xcode → your own registered device, with the debugger attached. Devices must be in the profile. For engineers, not testers.
Ad-Hoc
Build an .ipa, host it on an OTA install page (Bitrise public install page, Firebase App Distribution, Diawi…). Every tester's UDID must be registered and the profile regenerated. Hard cap ~100 devices/year/class.
TestFlight
Upload an App-Store-signed build to App Store Connect. Testers join by email / group — no UDID. Up to 100 internal + 10,000 external testers (external needs a light review).
App Store
Same App Store profile, but submitted for full App Review and released publicly.
If the destination is TestFlight, the profile must be App Store. Full stop.
This is the crux of the whole session. The goal was "designers install the ShowCase app via TestFlight." TestFlight only accepts App-Store-signed builds, so Ad-Hoc was never an option — even though Ad-Hoc feels simpler. The payoff for App Store signing is huge for this use case: zero UDID management. Designers come and go; nobody wants to register and re-register phones.
Part 7 — fastlane match: signing for teams
Everything above works for one developer on one Mac. It falls apart for a team + CI, for two reasons: (1) Apple limits distribution certificates, so you can't let everyone generate their own; (2) certificates depend on a private key that lives in one Keychain — a CI machine that didn't generate the key can't sign at all.
fastlane match solves this with one idea: store the shared distribution certificate (including its private key) and all the provisioning profiles in a private, encrypted git repository. Every machine — laptops and CI — runs match to download and install the same identity instead of creating new ones.
ios-matchencrypted .p12 (cert+key) + .mobileprovision files
fastlane match on any machine →profiles land in
~/Library/MobileDevice/Provisioning Profiles/One source of truth, encrypted with a passphrase. New CI box? Run match, you're signing in seconds.
match also imposes a naming convention on the profiles it creates: match {Type} {bundleid} — e.g. match AppStore com.example.designkit.ShowCase. That exact string becomes the profile's Name, which matters in the next part. A subtle trap we hit: the app_identifier list in the Matchfile is only a default; if your Fastfile lanes call match(app_identifier: [...]) with an explicit list, that list wins and the Matchfile is ignored. Adding a new bundle id means editing the lane, not just the Matchfile.
Part 8 — Where the profile must physically be
Creating a profile in the portal (or in the match repo) is not enough. The signing tool has to find it on the machine doing the build. There is one canonical location:
~/Library/MobileDevice/Provisioning Profiles/*.mobileprovision
How it gets there, and how a build refers to it, depends on the toolchain:
| Toolchain | How it finds the profile |
|---|---|
| Xcode (automatic) | Manages and installs profiles for you, matching by bundle id + capabilities. |
| fastlane match | Downloads from the encrypted repo into the folder above. |
| Bitrise CI | The certificate-and-profile-installer step installs whatever profiles/certs are uploaded to the Bitrise app's "Code Signing & Files" store into that folder. |
Bazel (rules_apple local_provisioning_profile) | Searches the folder above by the profile's Name field — not by bundle id, not by file path. |
Bazel resolves the profile by name, so the name in your BUILD config must equal the Name field inside the actual installed profile.
Our build config asked for match AppStore com.example.designkit.ShowCase (the match convention). A hand-made portal profile named showcase-adhoc-testflight would not be found even if it were the right type — the names don't match. Either name the portal profile to match, or point the build config at the real name.
Part 9 — Case study: the ShowCase failure
Now the whole session reads cleanly. The pipeline ran a release (App Store) build of //ShowCase:ShowCaseApp and died:
error: no provisioning profile was found named 'match AppStore com.example.designkit.ShowCase'Correct and expected: the certificate (team-scoped) was reusable, but the profile (bundle-id-scoped) for this brand-new app didn't exist anywhere yet — not in the portal, not in the match repo, not installed on the runner.
A profile was then downloaded to unblock it. The right move before trusting any .mobileprovision is to decode and inspect it:
security cms -D -i showcase-testflight.mobileprovision > /tmp/p.plist plutil -extract Name raw -o - /tmp/p.plist # showcase-adhoc-testflight plutil -extract TeamIdentifier.0 raw -o - /tmp/p.plist # ABCDE12345 ✅ plutil -extract Entitlements.get-task-allow raw -o - /tmp/p.plist # false plutil -extract ProvisionedDevices raw -o - /tmp/p.plist # 69 ← devices!
Team ✅, bundle id ✅ — but get-task-allow=false and a 69-device ProvisionedDevices list. Cross-reference the table in Part 5: that is an Ad-Hoc profile, despite the word "testflight" in its filename. App Store Connect would reject it. The fix wasn't to install it — it was to go back to the portal and create the App Store distribution type (Distribution → App Store Connect, no device selection) for the same App ID.
A profile's filename is a human label and lies freely. Its type lives in two fields you must decode to see.
Part 10 — Diagnostic reference
Keep these. They turn "signing is magic" into "signing is a plist I can read."
Decode any profile to readable XML:
security cms -D -i Some.mobileprovision # prints the plistIdentify a profile's type (run after piping the decode to a file, e.g. /tmp/p.plist):
plutil -extract Name raw -o - /tmp/p.plist plutil -extract AppIDName raw -o - /tmp/p.plist plutil -extract TeamIdentifier.0 raw -o - /tmp/p.plist plutil -extract Entitlements.application-identifier raw -o - /tmp/p.plist plutil -extract Entitlements.get-task-allow raw -o - /tmp/p.plist plutil -extract ExpirationDate raw -o - /tmp/p.plist plutil -extract ProvisionedDevices raw -o - /tmp/p.plist # errors/absent ⇒ App Store; a number ⇒ Ad-Hoc/Dev plutil -extract ProvisionsAllDevices raw -o - /tmp/p.plist # true ⇒ Enterprise
List what's installed on this machine:
ls -1 ~/Library/MobileDevice/Provisioning\ Profiles/
# then decode each to read its NameInspect signing certificates in your Keychain:
security find-identity -v -p codesigning # lists usable signing identitiesSee how an already-built app was signed:
codesign -dvvv --entitlements :- /path/to/Your.app
FAQ
I added a new app to the same team. Do I need a new certificate?
No. Certificates are team-scoped. The existing Apple Distribution certificate signs any app in the team. You do need a new App ID and a new provisioning profile, because both are bundle-id-scoped.
Why can't I just use my Ad-Hoc profile for TestFlight? It's distribution-signed.
TestFlight distribution is handled by Apple's store infrastructure, which requires an App Store profile (no device list). An Ad-Hoc profile carries a UDID allowlist and is meant for direct OTA installs; App Store Connect rejects it on upload.
The build says it can't find a profile, but I can see it in the Apple portal.
Existing in the portal ≠ installed on the build machine. It must be downloaded into ~/Library/MobileDevice/Provisioning Profiles/ (via Xcode, fastlane match, or a CI installer step). And if you build with Bazel, the profile's Name must match what your BUILD config asks for.
Development vs Ad-Hoc — both have my devices. What's the difference?
get-task-allow. Development profiles set it true (the app is debuggable and signed with a development cert); Ad-Hoc sets it false (release behaviour, signed with the distribution cert). Same device list, different runtime posture and certificate.
How long do these last?
Provisioning profiles typically expire after one year; certificates similarly. They expire independently, so always check ExpirationDate rather than assuming "it worked before."
Glossary
- Team ID
- Identifier for your Apple Developer account (e.g.
ABCDE12345). The scope for certificates. - Certificate
- A public/private key pair endorsed by Apple, proving who signed an app. Development (per-dev) or Distribution (team-shared).
- Private key
- The secret half of a certificate, kept in the Keychain. Without it you cannot sign — which is why CI needs it shared (see match).
- App ID
- A registered bundle id plus its allowed capabilities. Explicit or wildcard.
- Bundle id
- The app's unique reverse-DNS identifier, e.g.
com.example.designkit.ShowCase. - Entitlements
- Runtime permissions the app requests; must be a subset of what the App ID and profile grant.
- UDID
- Unique identifier of a physical device. Listed in Development and Ad-Hoc profiles.
- Provisioning profile
- Apple-signed file binding certificate(s) + App ID + (maybe) devices + entitlements + team. Embedded in the shipped app as
embedded.mobileprovision. - get-task-allow
- Entitlement flag;
true= debuggable (Development),false= release (Ad-Hoc / App Store). - ProvisionedDevices
- The UDID allowlist inside a profile. Present ⇒ Development or Ad-Hoc. Absent ⇒ App Store.
- Ad-Hoc
- Distribution profile with a device allowlist; for direct OTA installs, not TestFlight.
- App Store profile
- Distribution profile with no device list; required for TestFlight and the App Store.
- TestFlight
- Apple's beta distribution service. Accepts App-Store-signed builds; testers join by email, no UDID.
- fastlane match
- Stores the shared certificate and profiles in an encrypted git repo so all machines install the same signing identity. Names profiles
match {Type} {bundleid}. - codesign
- The macOS tool that signs an app bundle with your private key and embeds the profile.
- local_provisioning_profile
- The rules_apple Bazel rule that finds an installed profile by its Name field.