Why this happens
When you delete an expired provisioning profile from your device or from Xcode’s Accounts preferences, the Xcode project file (project.pbxproj) often retains the old profile’s UUID in the build settings. Xcode then tries to use that missing UUID during code signing, producing the error:
Code Sign Error: Provisioning Profile (long UUID string) can't be found.
This is especially common in older projects that have been migrated across Xcode versions. The stale reference can live at the project level, the target level, or both, and it may appear for specific SDKs (for example PROVISIONING_PROFILE[sdk=iphoneos*]). Until the reference is cleared, Xcode will keep looking for a profile that no longer exists.
How to fix it
1. Clean the project file manually (most reliable)
This method removes every stale UUID so Xcode forces a fresh selection.
- Close the project in Xcode.
- In Finder, right-click the
.xcodeprojfile and choose Show Package Contents. - Open
project.pbxprojin a plain-text editor (VS Code, BBEdit, TextEdit in plain-text mode). - Search for the UUID shown in the error message.
- Delete any line that contains
PROVISIONING_PROFILEorPROVISIONING_PROFILE_SPECIFIER, including SDK-specific variants such as:
PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB"; - Save the file and reopen the project in Xcode.
- Select the target → Signing & Capabilities (or Build Settings → Code Signing in older Xcode versions) and choose the correct profile from the dropdown.
Tip: If you use Xcode 13 or later with automatic signing, simply toggle Automatically manage signing off and back on after reopening; Xcode will regenerate the correct entries.
2. Change the profile in the target’s Build Settings (no text editor)
If you prefer to stay inside Xcode:
- In the Project Navigator, expand Targets and double-click your app target.
- Switch to the Build Settings tab.
- In the search field, type
provisioning. - For each Provisioning Profile row (Debug, Release, Any iOS SDK, etc.) that shows the old UUID or “Invalid Profile”, click the value and choose the correct profile from the pop-up menu.
- Do the same for Provisioning Profile Specifier if it appears.
- Clean the build folder (Product → Clean Build Folder) and build again.
Note: This is different from setting the profile at the project level. The target-level setting overrides the project level and is what the code-sign step actually reads.
How to prevent it
- Use Automatically manage signing (Xcode 8+) whenever possible; Xcode updates the UUIDs for you.
- When a profile expires, replace it in Xcode (Accounts → Manage Certificates/Profiles → Download) instead of deleting it manually from the device or Keychain.
- Keep the project file under version control; a quick
git diff project.pbxprojwill reveal stray UUID changes before they cause a build failure. - Avoid editing provisioning profiles in the Apple Developer portal while Xcode has the project open—close Xcode first, then refresh.
FAQ
Why does the error show a long UUID instead of the profile name?
Xcode stores provisioning profiles by their internal UUID in the project file. The human-readable name is only a lookup in the provisioning profile store; when the profile is removed, the lookup fails and the raw UUID surfaces in the error.
Can I fix this by deleting the DerivedData folder?
No. DerivedData holds build intermediates, not the project’s code-sign configuration. The stale UUID lives in project.pbxproj, so cleaning DerivedData alone will not help.
What if both fixes fail and the error persists?
Check for a xcodeproj project-level setting that overrides the target. In the Project Navigator, select the project (blue icon), go to Build Settings, search for provisioning, and clear any values there as well. Also verify that no .xcconfig file referenced by the target contains a hard-coded PROVISIONING_PROFILE line.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
