My workspace consists of projects with framework targets, and app project which uses these frameworks.
To build workspace with overridden provisioning profile I am using next command:
/usr/bin/xcodebuild -sdk iphoneos clean build -workspace <workspace-name>
-scheme <scheme-name> -configuration Release
PROVISIONING_PROFILE=<profile-uuid>
Profile is non-wildcard.
From the Xcode distribution build performs normally.
From command-line, the errors are generated because xcodebuild
also overrides provisioning profile for frameworks and tries to sign them.
Code Sign error: Provisioning profile does not match bundle identifier:
The provisioning profile specified in your build settings (“<profile-name>”)
has an AppID of “<profile-app-id>” which does not match your
bundle identifier “<framework-bundle-id>”.
That's strange, because when building from Xcode, after the final app is built, frameworks are re-signed with the app's provisioning profile, and signing of them during the building is not required.
How to avoid this issue?
UPD: Command-line build is performed by plugin on Continuous Integration system which overrides PROVISIONING_PROFILE variable. That's why it is crucial to keep using of that variable, not some user-defined ones. But seems like it's not possible. Xcode performs redundant signing of frameworks first with whatever-matching profile you specified, and then - with the application's provisioning profile when it installs frameworks into bundle, and there is no way to avoid this redundant first signing.
Answer from Apple that I've got on reported bug:
So currently they would prefer to keep redundant signing of frameworks during the workspace build.