How to build a workspace with frameworks from command line with overridden non-wildcard PROVISIONING_PROFILE

745 views Asked by At

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.

1

There are 1 answers

0
Eugene Dudnyk On BEST ANSWER

Answer from Apple that I've got on reported bug:

This issue behaves as intended based on the following:

Settings passed on the command-line to xcodebuild will override all instances of that setting across all targets being built. That's how it works.

In order to override only selected targets, you would need to do something tricky in your target set-up, for example:

In the target, assuming the target is named "MyTarget":

PROVISIONING_PROFILE=$(PROVISIONING_PROFILE_$(TARGET_NAME)) PROVISIONING_PROFILE_MyTarget=

And then in xcodebuild, you would do:

xcodebuild PROVISIONING_PROFILE_MyTarget=

If you have multiple targets you need to selectively override then you could do this for each of them, replacing 'MyTarget' in the setting name with the appropriate name for each target.

So currently they would prefer to keep redundant signing of frameworks during the workspace build.