Hi,
I am posting this in the hopes that it may save someone with a similar problem some time.
A build was failing with the following error:
Code Signing Error: Provisioning profile "FooBar" doesn't include signing certificate "iPhone Developer: foo bar (xxxxxxxxxxx)".
The build was done on the command line with:
xcodebuild OTHER_CODE_SIGN_FLAGS='--keychain /Users/me/Library/Keychains/Buildsystem' (and other parameters)
Before each build we create the Buildsystem keychain and import the certificates needed fo the build into it. The keychain is then removed after the build.
I could do the build locally and it would work, it was only on our build machine under jenkins that it failed.
After spending a lot of time on this I found the cause was that there was another certificate in the builds machine's login keychain that was being used for the code signing even though we had provided a keychain with the correct certificate and told the codsigning to use it. After deleting the bad certificate from teh login keychain everything worked.
So it looks like the -keychain has no effect or that codesigning searched the login keychain before the specified one.
Is there anyway to change this behavior?
The idea of using a special keychain for the build process was to avoid things like this.