Sub topic 9
Signing iOS apps: certificates, profiles, and Xcode
iOS refuses to install or run an app that Apple has not allowed. Code signing is how Apple, your team, and the device agree on who built the app and where it may run. This chapter covers the pieces involved and how to configure them in Xcode for a Flutter project.
This chapter assumes you have a Flutter app that runs in debug mode, a Mac with Xcode installed, and an Apple Developer Program membership (paid, US$99 per year). You also need the bundle identifier you chose in the app identity chapter. Building for a real device or the App Store is only possible on macOS.
What signing proves
A signed iOS app carries a cryptographic signature. The system checks two things before it runs the app:
- The code has not changed since it was signed.
- The signer is someone Apple trusts, and the app is allowed on this device or in this distribution channel.
Four objects make this work. They are easy to confuse, so this table separates them.
| Object | What it is | Where it lives |
|---|---|---|
| Signing certificate | A public/private key pair identifying you or your team. Apple signs the public half. | Private key in your Mac's Keychain, certificate on Apple's servers |
| App ID | The bundle identifier, plus the capabilities (such as Push Notifications) enabled for it | Apple Developer account |
| Device identifiers (UDIDs) | Unique IDs of registered test devices | Apple Developer account |
| Provisioning profile | A file that links a certificate, an App ID, and (for development and ad hoc) a list of devices | Embedded in the built app |
The provisioning profile is the glue. When you install an app, iOS reads the embedded profile and asks: is the certificate that signed this app listed in the profile, does the bundle identifier match, and is this device allowed?
Certificate and profile types
Which certificate and profile you need depends on what you are doing with the build.
| Purpose | Certificate | Profile type | Device limit |
|---|---|---|---|
| Run from Xcode on your own device | Apple Development | iOS App Development | Registered devices only |
| Share a build with specific testers outside TestFlight | Apple Distribution | Ad Hoc | 100 registered devices per device type per year |
| TestFlight and App Store | Apple Distribution | App Store | None |
| Company internal distribution (Enterprise Program) | Apple Distribution (enterprise) | In-House | Your employees only |
For this tutorial's goal, publishing through TestFlight and the App Store, you need an Apple Distribution certificate and an App Store profile. During development you need an Apple Development certificate and a development profile.
Automatic versus manual signing
Xcode offers two modes. Pick one per project and per target.
- Automatic signing. You choose a team. Xcode creates certificates, registers the App ID, registers connected devices, and generates and renews profiles as needed. It is the right default for most solo developers and small teams.
- Manual signing. You pick a certificate and a specific profile yourself. You must create and download them from the developer portal. This is common on CI machines and in teams that want exact control, because nothing changes silently.
A trade-off to know: automatic signing is fast to set up but can create new certificates when it cannot find the private key on a machine. Apple limits how many distribution certificates a team can hold, so repeated automatic signing on many Macs can hit that limit.
Configure automatic signing in Xcode
Flutter keeps the iOS project in the ios folder. Open the workspace, not the project file, because CocoaPods plugins live in the workspace.
open ios/Runner.xcworkspaceThen in Xcode:
- Select Runner in the project navigator (the blue icon at the top).
- Under Targets, select Runner.
- Open the Signing & Capabilities tab.
- Check Automatically manage signing.
- Choose your Team from the dropdown. If it is empty, add your Apple ID under Xcode > Settings > Accounts.
- Confirm the Bundle Identifier matches your app, for example
com.example.myapp.
Xcode now registers the App ID and creates a profile. A green status or a "Provisioning Profile" line with a profile name indicates success.
Signing for release
The Signing & Capabilities tab has separate settings for Debug, Release, and Profile configurations when you turn off automatic signing. With automatic signing on, Xcode picks a development identity for debug runs and a distribution identity when you archive.
When you run flutter build ipa --release, Flutter calls Xcode's build tooling, which signs with the settings in the Release configuration. If those are wrong, the build fails or produces an archive that App Store Connect rejects.
Manual signing step by step
Use this path when you want control, or when a CI machine builds the app.
- In the Apple Developer portal, open Certificates, Identifiers & Profiles.
- Under Identifiers, register an App ID that matches your bundle identifier and enable the capabilities you use.
- Under Certificates, create an Apple Distribution certificate. The portal asks for a Certificate Signing Request (CSR). Create one on your Mac with Keychain Access: Certificate Assistant > Request a Certificate From a Certificate Authority, and save it to disk.
- Download the issued certificate and double-click it. It installs into your login Keychain and pairs with the private key made when you created the CSR.
- Under Profiles, create an App Store profile. Select the App ID and the distribution certificate.
- Download the profile and double-click it, or let Xcode fetch it under Xcode > Settings > Accounts > Download Manual Profiles.
- In Xcode, uncheck Automatically manage signing, then pick the profile for the Release configuration.
You can verify that a usable identity exists with this command:
security find-identity -v -p codesigningThe output lists valid identities such as Apple Distribution: Your Name (TEAMID). If your certificate is missing, or listed as not valid, the private key is probably not in this Keychain.
Back up your private key
The certificate is public, but the private key exists only on the Mac that created the CSR. If you lose that Mac without a backup, you cannot sign with that certificate on another machine. You would revoke it and create a new one.
To move signing to another Mac or to a CI runner, export the identity from Keychain Access as a .p12 file, protected by a password. Import it on the new machine. Treat the .p12 like the Android keystore from earlier chapters: keep it private, backed up, and out of version control.
Capabilities and entitlements
Capabilities such as Push Notifications, Sign in with Apple, and Associated Domains are enabled per App ID. Xcode records them in an entitlements file, ios/Runner/Runner.entitlements, and the provisioning profile must grant the same entitlements.
If you add a capability with automatic signing, Xcode updates the App ID and regenerates the profile. With manual signing, you must enable the capability on the App ID in the portal and then create a new profile, because old profiles do not pick up the change.
How the signing flow fits together
Common errors and fixes
| Message or symptom | Likely cause | Fix |
|---|---|---|
| "Signing for Runner requires a development team" | No team selected on the Runner target | Choose a team in Signing & Capabilities |
| "No profiles for 'com.example.myapp' were found" | App ID not registered, or bundle identifier typo | Check the bundle identifier, or turn on automatic signing |
| "Failed to create provisioning profile. The app identifier cannot be registered" | Another team already owns this identifier | Choose a unique bundle identifier |
| "No signing certificate 'iOS Distribution' found" | Private key missing from this Mac's Keychain | Import the `.p12`, or create a new certificate |
| "Provisioning profile doesn't include the signing certificate" | Profile was built with a different certificate | Regenerate the profile and select the right certificate |
| "Provisioning profile doesn't include the ... entitlement" | Capability added after the profile was made | Enable it on the App ID, regenerate the profile |
| Device install fails with "Untrusted Developer" | Free or development certificate not yet trusted on the device | On the device, open Settings > General > VPN & Device Management and trust it |
| Build works in Xcode but `flutter build ipa` fails | Release configuration signing differs from Debug | Open Signing & Capabilities and fix the Release settings |
Edge cases to know
- Expiry. Certificates last one year, and App Store profiles are tied to them. When a distribution certificate expires, new builds fail to sign, but apps already on the store keep working. Renew before the date.
- Revoking a certificate. Revoking invalidates every profile that used it. Those profiles show as invalid until regenerated.
- Team roles. Only the Account Holder and Admins can create distribution certificates. An App Manager or Developer role may be unable to create or download them, which produces confusing permission errors.
- Simulator. The iOS Simulator does not need a profile, so simulator builds can succeed while device builds fail.
- Bundle identifier changes. Changing the identifier after setup makes the old App ID, profiles, and any TestFlight history unrelated to the new one. Decide early.
Exercise
A teammate's Mac builds the app fine with automatic signing. On a new CI machine, the build fails with "No signing certificate 'iOS Distribution' found". The certificate shows as valid in the Apple Developer portal. What is most likely missing, and what two things could you do?
Show answer
The private key is missing on the CI machine. The portal only holds the public certificate, and the private key lives in the Keychain of the Mac that created the certificate signing request. Either export the identity as a password-protected .p12 file from the original Mac and import it on the CI machine (along with the App Store profile), or create a new Apple Distribution certificate from a CSR generated on the CI machine and make a new profile that includes it.
Exercise
You enable the Push Notifications capability on your App ID in the portal, but your existing manually managed App Store profile still causes an entitlement error when building. Why, and what should you do?
Show answer
A profile is a snapshot created at a point in time. It does not update when the App ID changes. Regenerate the App Store profile in the portal so it includes the new entitlement, download it, and select it in Xcode for the Release configuration.