Xcode 15.4 code signing error with the wrong provisioning profile bundle ID
Release was supposed to go out at four and the archive that came out of Xcode wouldn't install on my phone. I'd generated a fresh Ad Hoc profile that morning because the old one expired, dropped it into Xcode, and picked it in Signing & Capabilities. Xcode 15.4, deployment target iOS 17.5, a physical iPhone on iOS 17.5.1. The build succeeded. The install failed with:
## The error
Code signing is required for product type 'Application' in SDK 'iOS 17.5'
Which is a weird message given I had just selected a profile. A second build produced something more useful in the Report navigator:
Signing for "Northwind" requires a development team. Select a development team in the Signing & Capabilities editor.
Both messages showed up depending on whether I built the Debug or Release scheme. That was the first clue.
## What I checked first
I listed the installed signing identities:
$ security find-identity -v -p codesigning
1) 8F3A2C1D9E4B7A0C5D6E1F2A3B4C5D6E7F8A9B0C "Apple Development: Sam Rivera (7KQ4TZ9ABC)"
2) 2B1C0D9E8F7A6B5C4D3E2F1A0B9C8D7E6F5A4B3C "iPhone Distribution: Northwind Labs (7KQ4TZ9ABC)"
2 valid identities found
So the certs were there. Next I looked at what the profile actually contained, because the bundle ID was the thing I'd changed the day before, from com.northwind.app to com.northwind.app.prod:
$ security cms -D -i ~/Downloads/Northwind_Ad_Hoc.mobileprovision | plutil -extract Entitlements.application-identifier raw -
7KQ4TZ9ABC.com.northwind.app
There it was. The profile was for the old bundle ID. I'd changed PRODUCT_BUNDLE_IDENTIFIER in the project and generated a profile from the App ID that I happened to click first in the portal.
## The part that wasted an hour
Xcode's "Automatically manage signing" was on for Debug and off for Release. So Debug rebuilt the profile from scratch with the current bundle ID and worked fine. Release used the manually downloaded file with the stale App ID and failed. Both schemes looked identical in the scheme editor, which is why I kept missing it.
I confirmed with:
grep -n "PRODUCT_BUNDLE_IDENTIFIER\|CODE_SIGN_STYLE\|PROVISIONING_PROFILE_SPECIFIER" Northwind.xcodeproj/project.pbxproj
One more thing that would have saved time earlier: the file name a profile gets in the portal tells you nothing about the App ID, but the application-identifier entitlement does. plutil -p on the downloaded .mobileprovision prints the whole payload if you don't want to pipe through security cms. I checked the certificate expiry too, since that was the reason I regenerated the profile that morning, and the new distribution cert was valid for another eleven months.
## The fix
Created a new App ID com.northwind.app.prod in the developer portal, regenerated the Ad Hoc profile with the same distribution certificate, and turned off automatic signing for both schemes so they behave the same. Then cleaned derived data, because Xcode will happily keep signing with a cached profile:
rm -rf ~/Library/Developer/Xcode/DerivedData/Northwind-*
xcodebuild -project Northwind.xcodeproj -scheme Northwind-Release -configuration Release \
-destination 'generic/platform=iOS' -allowProvisioningUpdates clean archive \
-archivePath /tmp/Northwind.xcarchive
The archive installed on the first try. Still not sure why Xcode didn't just say "bundle ID doesn't match profile". Maybe it does in Xcode 16 and I'm stuck on 15.4 for another month.