Writing
Mobile English

iOS Code Signing in CI, Explained Like You're Angry About It

Certificates, provisioning profiles, and why 'Automatically manage signing' betrays you on a build machine - a working manual setup.

  • Published
  • 1 min read

Every mobile engineer has lost an afternoon to No signing certificate "iOS Distribution" found. Signing is not hard; it is three moving parts that must agree, on a machine that is not yours.

The three parts

  • Certificate (who signs): a private key + Apple-issued cert, exported as .p12.
  • Provisioning profile (what may be signed): binds an app ID, a cert, and capabilities.
  • The build machine’s keychain (where signing happens): must hold the p12, unlocked.

“Automatically manage signing” works on your laptop because Xcode can talk to your Apple ID. CI has no Apple ID session - and unless you wire up an App Store Connect API key, manual signing is the predictable choice there.

A CI recipe that keeps working

bash
# 1. temp keychain, so we never touch the runner's login keychain
security create-keychain -p "$KC_PASS" build.keychain
security unlock-keychain -p "$KC_PASS" build.keychain
security import cert.p12 -k build.keychain -P "$P12_PASS" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$KC_PASS" build.keychain
security list-keychains -d user -s build.keychain

# 2. profile where Xcode 16+ looks for it
mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles
cp profile.mobileprovision ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/

# 3. explicit, no magic
xcodebuild archive -scheme App \
  CODE_SIGN_STYLE=Manual \
  PROVISIONING_PROFILE_SPECIFIER="AppStore Profile"

Store the p12 and profile as CI secrets, base64-encoded. Rotate yearly on a calendar reminder - certificates expire exactly when you are on leave. That is not superstition; it is scheduling.