Details

Description

Since Xcode 9, builds that use manual code signing require that a provisioning profile is specified in the exportOptions.plist when performing an export operation.

The help for xcodebuild in Xcode 9 states:

provisioningProfiles : Dictionary

For manual signing only. Specify the provisioning profile to use for each executable in your app. Keys in this dictionary are the bundle identifiers of executables; values are the provisioning profile name or UUID to use.

It would probably require an extra field in the xcodebuild plugin config to allow a profile to be specified by name orUUID, and if specified, include it in the generated exportOptions plist. Or, possibly allow the option of specifying your own exportOptionsPlist that is used instead of the generated one, if specified.

Without this option, projects that use manual code signing cannot build with jenkins and this plugin.

Where I have parameters for EXPORT_METHOD, TEAM_ID, and PROVISIONING_PROFILE_NAME. (The other parameters are ones specific to my jobs that I use to build up the resulting ipa file name.) You also have to make sure you check the Create archive option in the Xcode build options.

Scott Gruby
added a comment - 2017-09-14 13:51 This particular part of the plugin seems to be problematic with each Xcocde upgrade. I finally made a script that is invoked after the Xcode build step using something like:
${WORKSPACE}/Common/Scripts/archive.swift ${EXPORT_METHOD} ${TEAM_ID} "${WORKSPACE}/Build" "${WORKSPACE}" "${PROVISIONING_PROFILE_NAME}"
mv "${WORKSPACE}" /*.ipa "${WORKSPACE}/${APP_NAME}-${BRANCH}-${CONFIGURATION}-${MAJOR_MINOR_VERSION}-${SHORT_VERSION}-${FULL_BUILD_DATE}.ipa"
Where I have parameters for EXPORT_METHOD, TEAM_ID, and PROVISIONING_PROFILE_NAME. (The other parameters are ones specific to my jobs that I use to build up the resulting ipa file name.) You also have to make sure you check the Create archive option in the Xcode build options.
I hope this helps others.

Thanks to the nguyen hoang I was able to work around the problem. Here is what I did:

Turn off "Pack application, build and sign .ipa?" and turn on "Generate Archive?" under general build settings

Add an Execute Shell build step after your Xcode step to generate the export_options.plist as above. The environment variables there aren't provided by Jenkins, so you'll have to fill in your own values. Also, I think "signingCertificate" needs to actually be "installerSigningCertificate" and I had to add a "compileBitcode" key with value of <false/>

Add another Execute Shell build step to generate the ipa. It will look something like this

xcodebuild -exportArchive \
-archivePath [path to the archive you generated in step 1, it will be in ${BUILD_DIR}] \
-exportPath [the folder where you want your IPA stored] \
-exportOptionsPlist [the file you created in step 2]

David Whittaker
added a comment - 2017-09-30 01:37 Thanks to the nguyen hoang I was able to work around the problem. Here is what I did:
Turn off "Pack application, build and sign .ipa?" and turn on "Generate Archive?" under general build settings
Add an Execute Shell build step after your Xcode step to generate the export_options.plist as above. The environment variables there aren't provided by Jenkins, so you'll have to fill in your own values. Also, I think "signingCertificate" needs to actually be "installerSigningCertificate" and I had to add a "compileBitcode" key with value of <false/>
Add another Execute Shell build step to generate the ipa. It will look something like this
xcodebuild -exportArchive \
-archivePath [path to the archive you generated in step 1, it will be in ${BUILD_DIR}] \
-exportPath [the folder where you want your IPA stored] \
-exportOptionsPlist [the file you created in step 2]
That allowed me to get an IPA built with manual signing. Good luck!

Since I have a bunch of targets and configurations to be building and archiving, I created a script to extract the signing settings from the build configuration (plus some parameters can be tunned/added too) to automatically create an exportOptions.plist.

With that, I "simply" ran xcodebuild -exportArchive to get my ipa.

But let me share a big bump in my experience, just in case it may help somebody out there:

When executing xcodebuild -exportArchive through an ssh session, it failed with a segmentation fault. The logs clarified nothing by failing with an "unknown error -1=ffffffffffffffff". Same executed locally just works. As far as I could understand codesign fails because xcodebuild can't reach the keys on the keychain while running on ssh. Will try to really know why, but meanwhile, just run your experiments on the machine itself .

Ferran Poveda
added a comment - 2017-10-16 21:51 - edited On the same boat here!
Since I have a bunch of targets and configurations to be building and archiving, I created a script to extract the signing settings from the build configuration (plus some parameters can be tunned/added too) to automatically create an exportOptions.plist.
With that, I "simply" ran xcodebuild -exportArchive to get my ipa.
But let me share a big bump in my experience, just in case it may help somebody out there:
When executing xcodebuild -exportArchive through an ssh session, it failed with a segmentation fault. The logs clarified nothing by failing with an "unknown error -1=ffffffffffffffff". Same executed locally just works. As far as I could understand codesign fails because xcodebuild can't reach the keys on the keychain while running on ssh. Will try to really know why, but meanwhile, just run your experiments on the machine itself .

BTW, I've seen there is a PR on Github for an update to the plugin that would solve us having to workaround the signing like this.

But, as far as I understand, it is just able to ask for an explicit configuration rather than taking one from the build settings. Even though I have 0 experience on the internals of this Xcode plugin I may be able to help to get this included somehow. Let me know if you'd be interested in such feature, and scream loudly if you know about the Xcode plugin guts, and want to collaborate on doing it.

Ferran Poveda
added a comment - 2017-10-16 21:55 - edited BTW, I've seen there is a PR on Github for an update to the plugin that would solve us having to workaround the signing like this.
But, as far as I understand, it is just able to ask for an explicit configuration rather than taking one from the build settings. Even though I have 0 experience on the internals of this Xcode plugin I may be able to help to get this included somehow. Let me know if you'd be interested in such feature, and scream loudly if you know about the Xcode plugin guts, and want to collaborate on doing it.

Alkesh Fudani
added a comment - 2017-11-24 01:12 Hi All,
What was the final solution to set up the jenkins for xcode 9? Can you please help me with the export plist creation and setting up export_options?
Also, will it require fastlane also to be installed on ci server?
please help, thanks in advance.

nguyen hoang, I am using Jenkins and I followed all the instructions given in your comment, but the jenkins still fails to generate the build, I have attached screenshots of my export_options file and the error given in jenkins console. Any help appreciated.

Also, further to this, I have jenkins setup for multiple provisioning profiles using multiple bundle ids in xcode 8.3, so for xcode 9 should I make multiple export options files? or I can specify array of bundle id, provisioning profile, team id in the same file?

Alkesh Fudani
added a comment - 2017-11-26 23:53 - edited nguyen hoang , I am using Jenkins and I followed all the instructions given in your comment, but the jenkins still fails to generate the build, I have attached screenshots of my export_options file and the error given in jenkins console. Any help appreciated.
Also, further to this, I have jenkins setup for multiple provisioning profiles using multiple bundle ids in xcode 8.3, so for xcode 9 should I make multiple export options files? or I can specify array of bundle id, provisioning profile, team id in the same file?

I have already added the provisioning profile inside Jenkins Custom xcodebuild arguments*section by passing the PROVISIONING_PROFILE, PROVISIONING_PROFILE_SPECIFIER, CODE_SIGN_IDENTITY, CODE_SIGN_STYLE and DEVELOPMENT_TEAM however, it still shoots the same error message. Besides, I also pass the ExportOptions.plist file in the Build phases Run script option but it seems that Xcode generates its own ExportOptions.plist(*enterpriseTEAMIDExport.plist) and ignores mine. When I open enterpriseTEAMIDExport.plist file it only contains the teamid and the method of export and so, it doesn't find the provisioning profile.

So, how can I tell xcode to use my ExportOptions.plist file instead? I have followed the image here but unable to find it inside Xcode 9. Also, this post doesn't relate to me.

Another important thing is that I am able to generate the ipa using my own ExportOptions.plist file from command line xcodebuild tool using this command as follows:

Ronak Patel
added a comment - 2017-12-22 16:54 nguyen hoang I have followed the steps that you have mentioned in this ticket. Also, I have followed Alkesh Fudani 's comments as he is also using Jenkins to build his ios apps.
I am using xcode plugin (version 2.0.1) with jenkins to generate builds for our multi-targeted app.
With Xcode 9, our jenkins build configuration is able to generate the archive but fails to create the ipa. The error message is as follows:
Error Domain=IDEProvisioningErrorDomain Code=9 ""test.app" requires a provisioning profile." UserInfo={NSLocalizedDescription="test.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list. }
I have already added the provisioning profile inside Jenkins Custom xcodebuild arguments*section by passing the PROVISIONING_PROFILE, PROVISIONING_PROFILE_SPECIFIER, CODE_SIGN_IDENTITY, CODE_SIGN_STYLE and DEVELOPMENT_TEAM however, it still shoots the same error message. Besides, I also pass the ExportOptions.plist file in the Build phases Run script option but it seems that Xcode generates its own ExportOptions.plist(*enterpriseTEAMIDExport.plist ) and ignores mine. When I open enterpriseTEAMIDExport.plist file it only contains the teamid and the method of export and so, it doesn't find the provisioning profile.
So, how can I tell xcode to use my ExportOptions.plist file instead? I have followed the image here but unable to find it inside Xcode 9. Also, this post doesn't relate to me.
Another important thing is that I am able to generate the ipa using my own ExportOptions.plist file from command line xcodebuild tool using this command as follows:
xcodebuild -exportArchive -archivePath archive.xcarchive -exportPath /my/export/path -exportOptionsPlist options.plist
So, I don't know why it doesn't work with Jenkins Xcode plugin.
Any help is much appreciated.
Thanks!

It looks like it's problem of the plugin not of Xcode or they do have a option for using custom plist file that you don't know yet. I don't use Jenkins Xcode plugin for iOS build so can not give it a try with my Jenkins.

Which version of Xcode integration plugin are you using? Is it the latest one? I do think it has a option for using custom plist file when exporting ipa executable.

nguyen hoang
added a comment - 2017-12-23 04:35 Hey Ronak Patel !
It looks like it's problem of the plugin not of Xcode or they do have a option for using custom plist file that you don't know yet. I don't use Jenkins Xcode plugin for iOS build so can not give it a try with my Jenkins.
Which version of Xcode integration plugin are you using? Is it the latest one? I do think it has a option for using custom plist file when exporting ipa executable.

Ronak Patel
added a comment - 2017-12-23 17:38 Hello nguyen,
Thanks for your prompt response. I am using the latest version of xcode plugin (2.0.1).
I have read their documentation but can't find a way to use my custom plist file. If you can't find anything, that would be a great help.
Also, if there is way to pass my custom plist file as a custom argument, it would be a great thing to know.
Thanks again.

At present, I am using the same approach to generate builds using xcodebuild command line. However, I have a project with 15 targets. So, don't you think it is time consuming to generate build for each target one by one? This leads to my other question which is:

2. Would it be much easier to setup up multi-targeted builds using Fastlane? It's because I already have a Jenkins setup running so..

Ronak Patel
added a comment - 2017-12-26 14:45 Hi Nguyen,
Thanks, once again.
At present, I am using the same approach to generate builds using xcodebuild command line. However, I have a project with 15 targets. So, don't you think it is time consuming to generate build for each target one by one? This leads to my other question which is:
2. Would it be much easier to setup up multi-targeted builds using Fastlane? It's because I already have a Jenkins setup running so..
Looking forward for your help.
Thanks

nguyen hoang
added a comment - 2017-12-26 15:03 Seems that in your case, you wanna have 15 ipa executable for 15 targets I've never tried it before but found that Fastlane does support that. Give it a go.
https://github.com/fastlane/fastlane/issues/88
https://docs.fastlane.tools/faqs/ (Multiple targets of the same underlying app)

Jay Trivedi
added a comment - 2018-04-26 10:20
Ronak Patel , Currently Kazuhide Takahashi just merged updated code on github repository of [xcode-jenkins plugin| https://github.com/jenkinsci/xcode-plugin .]
Still, the release of that code is pending. Once they release this update for this plugin will be available.

I just updated to Jenkins 2.122 and xcode-plugin 2.0.2. We run several test slaves with MacOS, one of the having the version 10.11.6 (El Captain). After the update, the builds on this machine failes (the machines running newer MacOS versions work just fine) with the following message:

David Eklund
added a comment - 2018-05-18 06:59 - edited I just updated to Jenkins 2.122 and xcode-plugin 2.0.2. We run several test slaves with MacOS, one of the having the version 10.11.6 (El Captain). After the update, the builds on this machine failes (the machines running newer MacOS versions work just fine) with the following message:
$ /usr/bin/xcodebuild -scheme "App" -workspace /Users/user/Jenkins/BuildWorkspace/App.xcworkspace -configuration Release clean build -allowProvisioningUpdates
xcodebuild: error: invalid option '-allowProvisioningUpdates'
This fix seems like a probable culprit. Is it in 2.0.2? If so, is there a work around?

Stephan Wezel
added a comment - 2018-05-18 09:25 - edited -allowProvisioningUpdates seems to be an option added with xcode 9
https://www.developerinsider.in/whats-new-in-xcode-9
David Eklund : Which xcode version do you use?