Understand the complete code signing process for App Store distribution.
Code Signing Overview
# Code signing = Identity + Entitlements + Provisioning Profile
# Required for: Device testing, TestFlight, App Store
# Managed by: Xcode (automatic) or Manual (CI/CD)Certificates
# Types:
# - Development: Run on devices during development
# - Distribution: App Store, Ad Hoc, Enterprise
# Certificate = Public key + Private key
# Private key stays in Keychain
# Public key in certificate
# Create Development Certificate:
# 1. Xcode → Settings → Accounts → Manage Certificates → + → Apple Development
# 2. Or: Keychain Access → Certificate Assistant → Request from CA
# Create Distribution Certificate:
# 1. Apple Developer Portal → Certificates → + → Apple Distribution
# 2. Download .cer, double-click to install# View certificates
security find-identity -v -p codesigning
# Export certificate (for CI)
security export -k login.keychain -t certs -f pkcs12 -o certs.p12 -P "password"
# Import certificate
security import certs.p12 -k login.keychain -P "password" -T /usr/bin/codesignProvisioning Profiles
# Profile = Certificate + App ID + Devices + Entitlements
# Types:
# - Development: For debugging on registered devices
# - Ad Hoc: For testing on registered devices (no Xcode)
# - App Store: For TestFlight and App Store submission
# - Enterprise: For internal distribution (Enterprise Program)
# App ID: Bundle ID + Capabilities
# Example: com.example.myapp with Push Notifications, Wallet, etc.
# Create in Apple Developer Portal:
# 1. Profiles → + → Select type
# 2. Select App ID
# 3. Select Certificate(s)
# 4. Select Devices (for dev/adhoc)
# 5. Name and Generate
# 6. Download .mobileprovision# View profile
security cms -D -i MyApp.mobileprovision
# Install profile
cp MyApp.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/
# List profiles
ls ~/Library/MobileDevice/Provisioning\ Profiles/Entitlements
<!-- MyApp.entitlements -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- App Groups (shared data) -->
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.example.myapp</string>
</array>
<!-- Push Notifications -->
<key>aps-environment</key>
<string>production</string>
<!-- Wallet -->
<key>com.apple.developer.pass-type-identifiers</key>
<array>
<string>pass.com.example.myapp</string>
</array>
<!-- HealthKit -->
<key>com.apple.developer.healthkit</key>
<true/>
<!-- HomeKit -->
<key>com.apple.developer.homekit</key>
<true/>
<!-- iCloud -->
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.example.myapp</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<!-- Keychain Sharing -->
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.example.myapp</string>
</array>
<!-- Network Extensions -->
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>app-proxy-provider</string>
<string>content-filter</string>
</array>
<!-- SiriKit -->
<key>com.apple.developer.siri</key>
<true/>
<!-- App Clips -->
<key>com.apple.developer.app-clips</key>
<array>
<string>com.example.myapp.Clip</string>
</array>
</dict>
</plist>Automatic vs Manual Signing
# Automatic (Recommended for Development)
# Xcode manages certificates and profiles
# Settings: Signing & Capabilities → Automatically manage signing
# Team: Select your team
# Bundle ID: Auto-registered
# Manual (Required for CI/CD)
# You manage certificates and profiles
# Use with Fastlane Match or manual import
# Settings: Signing & Capabilities → Uncheck Automatically manage signing
# Provisioning Profile: Select .mobileprovision file
# Signing Certificate: Select from keychainFastlane Match
# Setup (one time)
fastlane match init
# Enter git repo URL for certs
# Enter passphrase
# Generate certificates
fastlane match development
fastlane match appstore
# In CI (readonly)
fastlane match development --readonly
fastlane match appstore --readonly
# Matchfile
git_url("https://github.com/your-org/certificates.git")
storage_mode("git")
type("development")
app_identifier(["com.example.myapp"])
username("your@appleid.com")
team_id("YOUR_TEAM_ID")
readonly(false)
keychain_name("fastlane_tmp_keychain")# Fastlane lanes for CI
lane :setup_certificates do
create_keychain(
name: "fastlane_tmp_keychain",
password: ENV["MATCH_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
add_to_search_list: true
)
match(
type: "appstore",
readonly: true,
keychain_name: "fastlane_tmp_keychain",
keychain_password: ENV["MATCH_PASSWORD"]
)
endCI/CD Code Signing
# GitHub Actions
- name: Import Certificates
run: |
# Create temporary keychain
security create-keychain -p "$MATCH_PASSWORD" fastlane_tmp_keychain
security default-keychain -s fastlane_tmp_keychain
security unlock-keychain -p "$MATCH_PASSWORD" fastlane_tmp_keychain
security set-keychain-settings -t 3600 -l fastlane_tmp_keychain
# Import certificates via Fastlane Match
bundle exec fastlane match appstore --readonly
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APP_STORE_CONNECT_API_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY }}
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}# Xcode Cloud: Certificates managed automatically
# Or import manually in Xcode Cloud settingsDebugging Signing Issues
# Check code signature
codesign -dv --verbose=4 MyApp.app
# Verify signature
codesign --verify --verbose=4 MyApp.app
# Check entitlements
codesign -d --entitlements :- MyApp.app
# Check provisioning profile in app
security cms -D -i MyApp.app/embedded.mobileprovision
# Common errors:
# "No signing certificate found" → Import certificate to keychain
# "Provisioning profile doesn't match" → Check bundle ID, entitlements
# "Certificate expired" → Renew in Developer Portal
# "No profiles found" → Download and install profileApp Store Connect API Key (Modern)
# Replace username/password with API Key
# 1. App Store Connect → Users and Access → Keys
# 2. Generate API Key (Admin or App Manager)
# 3. Download .p8 file
# 4. Note: Key ID, Issuer ID
# Use in Fastlane
# api_key_path: "./fastlane/app_store_connect.json"
# Use in xcodebuild
xcodebuild -exportArchive \
-archivePath build/MyApp.xcarchive \
-exportPath build/ipa \
-exportOptionsPlist ExportOptions.plist \
-authenticationKeyPath ./AuthKey_XXXXXX.p8 \
-authenticationKeyID XXXXXXXX \
-authenticationKeyIssuerID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXDistribution Methods
# App Store (TestFlight → App Store)
# - App Store provisioning profile
# - Distribution certificate
# - Upload via Transporter, altool, or Fastlane
# Ad Hoc (Internal testing)
# - Ad Hoc provisioning profile (max 100 devices)
# - Distribution certificate
# - Install via diawi.com, installonair.com, or MDM
# Enterprise (Internal only - Enterprise Program)
# - Enterprise provisioning profile
# - Enterprise distribution certificate
# - No device limit, no App Store review
# Development (Debugging)
# - Development provisioning profile
# - Development certificate
# - Xcode installs directlyChecklist for Release
# Pre-Release Signing Checklist
## Certificates
- [ ] Distribution certificate valid (not expired)
- [ ] Certificate installed in keychain (or Match)
- [ ] Private key available
## Provisioning Profile
- [ ] App Store profile created
- [ ] Bundle ID matches exactly
- [ ] All required capabilities included
- [ ] Profile not expired
- [ ] Profile downloaded and installed
## Entitlements
- [ ] aps-environment: production (for push)
- [ ] App Groups configured
- [ ] iCloud containers configured
- [ ] Keychain sharing groups
- [ ] All capabilities match profile
## Build Settings
- [ ] Code Signing Style: Manual (CI) / Automatic (local)
- [ ] Provisioning Profile: Correct UUID
- [ ] Signing Certificate: Correct certificate
- [ ] Team ID correct
## Archive & Export
- [ ] Archive builds successfully
- [ ] Export options: method = app-store
- [ ] IPA validates in Transporter
- [ ] Upload to TestFlight succeeds
- [ ] TestFlight processing completesTry It
Create certificates in Developer Portal. Create provisioning profiles. Configure Xcode signing. Test with Fastlane Match. Build and export IPA.
# Test locally
xcodebuild archive -scheme MyApp -configuration Release
xcodebuild -exportArchive -exportOptionsPlist ExportOptions.plistCode Signing mastery
- Create Development and Distribution certificates
- Create App Store provisioning profile
- Configure entitlements for push, iCloud, App Groups
- Set up Fastlane Match with git repo
- Configure CI/CD with Match (readonly)
- Build and export IPA locally
- Upload to TestFlight via Fastlane
- Debug a signing issue
Code signing = Certificate + Profile + Entitlements. Automatic for dev, Manual for CI. Match manages certs in git. App Store Connect API Key replaces passwords. Verify with codesign. Check entitlements match profile.
Resources
- Code Signing Guide: https://developer.apple.com/documentation/xcode/distributing-your-app-for-beta-testing-and-releases
- Fastlane Match: https://docs.fastlane.tools/actions/match/
- App Store Connect API: https://developer.apple.com/app-store-connect/api/