-
Bug
-
Resolution: Unresolved
-
Blocker
-
Xcode 9 (beta 2), xcodebuild plugin 2.0
-
Powered by SuggestiMate
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.
the console output for a failing build:
$ /usr/bin/xcodebuild -exportArchive -archivePath "/pathto/app.xcarchive" -exportPath "/pathto/export" -exportOptionsPlist "/pathto/ad-hocTEAMIDExport.plist"
2017-07-13 12:02:52.196 xcodebuild[5043:2359795] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/sh/pathto/logs'.
2017-07-13 12:02:53.262 xcodebuild[5043:2359795] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fc0fdfd8720>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed." UserInfo={NSLocalizedDescription=Locating signing assets failed., IDEDistributionSigningAssetStepUnderlyingErrors=(
{{ "Error Domain=IDEProvisioningErrorDomain Code=9 \"\"MyApp.app\" requires a provisioning profile.\" UserInfo={NSLocalizedDescription=\"MyApp.app\" requires a provisioning profile., NSLocalizedRecoverySuggestion=Select a provisioning profile for the \"Default\" build configuration in the project editor.}"}}
)}
error: exportArchive: "MyApp.app" requires a provisioning profile.Error Domain=IDEProvisioningErrorDomain Code=9 ""MyApp.app" requires a provisioning profile." UserInfo={NSLocalizedDescription="MyApp.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Select a provisioning profile for the "Default" build configuration in the project editor.}** EXPORT FAILED **
- is duplicated by
-
JENKINS-48256 Unable to create ipa for iOS project with Xcode 9, While it is successful for Xcode < 9
-
- Resolved
-
- relates to
-
JENKINS-47744 xcodebuild export step fails due to empty exportPlist
-
- Open
-
[JENKINS-45509] Xcode 9 requires provisioning profile to be specified when using manual code signing
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.
I'll give a try to the workaround suggested by Scott, however a real solution for the problem would be highly appreciated.
Same issue here. Can't get Jenkins to properly make a build with or without manual signing at this point.
Create a plist file for export options like this:
# Create .plist file for exporting echo " <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>method</key> <string>enterprise</string> <key>provisioningProfiles</key> <dict> <key>"$BUNDLE_ID"</key> <string>"$TARGET_PROVISIONING_PROFILE_SPECIFIER"</string> </dict> <key>signingCertificate</key> <string>"$SIGNING_CERTIFICATE"</string> <key>teamID</key> <string>"$TEAM_ID"</string> <key>signingStyle</string> <string>manual</string> </dict> </plist> " > ${WORKSPACE}/export_options.plist
Use this export_options.plist file for export_options in fastlane gym command build
# Using for Xcode 9 fastlane gym --workspace Example.xcworkspace \ --scheme ${SCHEME} \ --sdk 'iphoneos' \ --configuration Staging \ --output_directory ${BUILD_FOLDER} \ --output_name app_name.ipa \ --codesigning_identity "$SIGNING_CERTIFICATE" \ --xcargs "PROVISIONING_PROFILE_SPECIFIER='${TARGET_PROVISIONING_PROFILE_SPECIFIER}' \ --export_options "${WORKSPACE}/export_options.plist" \ --verbose \ --buildlog_path ${WORKSPACE}
Give it a go.
Thanks to the nguyenhoang 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!
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.
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.
alkesh_f, please see the my comment above. That helps creating export plist file used in exporting ipa file in Xcode 9.
Installing fastlane on CI server is definitely required if you wanna use fastlane to build an iOS application.
nguyenhoang, 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_f If you're using multiple provisioning profiles for multiple bundle id(s), make sure you include those in exporting plist file like following:
# Create .plist file for exporting echo " <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>method</key> <string>enterprise</string> <key>provisioningProfiles</key> <dict> <key>$BUNDLE_ID_1</key> <string>"$TARGET_PROVISIONING_PROFILE_SPECIFIER_1"</string> <key>$BUNDLE_ID_2</key> <string>"$TARGET_PROVISIONING_PROFILE_SPECIFIER_2"</string> <key>$BUNDLE_ID_3</key> <string>"$TARGET_PROVISIONING_PROFILE_SPECIFIER_3"</string> </dict> <key>signingCertificate</key> <string>"$CODESIGNING_IDENTITY"</string> <key>teamID</key> <string>$TEAM_ID</string> <key>signingStyle</string> <string>manual</string> </dict> </plist> " > ${WORKSPACE}/export_options.plist
TARGET_PROVISIONING_PROFILE_SPECIFIER_1='<TEAM_ID>/<PROFILE_NAME>'
Example:
TARGET_PROVISIONING_PROFILE_SPECIFIER_1='M7T5ABXCF/comProvisioningProfileExample'
In your case:
TEAM_ID=M7T5YNZ969
CODESIGNING_IDENTITY='iPhone Distribution: XXXXXXX'
CODESIGNING_IDENTITY is name of certificate that you're going to use to sign the app. Using command
security find-identity -v -p codesigning
to find appropriate signing identity.
Thanks for you help, I am successful at configuring the CI set up now..
nguyenhoang I have followed the steps that you have mentioned in this ticket. Also, I have followed alkesh_f'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!
Hey ronakpatel786!
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.
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.
Hey ronakpatel786!
- Suggest a workaround in your case: Set to skip export .ipa and manually export ipa with custom plist file with xcodebuild command line: xcodebuild -exportArchive -archivePath archive.xcarchive -exportPath /my/export/path -exportOptionsPlist options.plist
- Do you wanna use Faslane for your iOS builds? It's easy to setup a build.
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
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)
Yes, very true . I will take a look at these docs and see how it goes.
Thanks a lot, nguyenhoang.
_How to Add a profile to the "provisioningProfiles" dictionary in your Export Options property list through jenkins.?? _
Command shell:
xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/YourProject.xcarchive -exportPath ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/archive -exportOptionsPlist
${WORKSPACE}/ExportOptions.plist
Getting error:
2018-02-01 17:11:04.046 xcodebuild[57285:71980734] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fe61c53aff0>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed." UserInfo={NSLocalizedDescription=Locating signing assets failed., IDEDistributionSigningAssetStepUnderlyingErrors=(
"Error Domain=IDEProvisioningErrorDomain Code=9 \"\"MobileXXXXX.app\" requires a provisioning profile.\" UserInfo=
)}
error: exportArchive: "MobileXXXXX.app" requires a provisioning profile.
Error Domain=IDEProvisioningErrorDomain Code=9 ""MobileXXXXX.app" requires a provisioning profile." UserInfo={NSLocalizedDescription="MobileXXXXX.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
-
- EXPORT FAILED **
gauravborole You need to mention provisioning profile in ExportOptions.plist file.
Code changed in jenkins
User: Kazuhide Takahashi
Path:
src/main/java/au/com/rayh/ProvisioningProfile.java
src/main/java/au/com/rayh/XCodeBuilder.java
src/main/resources/au/com/rayh/Messages.properties
src/main/resources/au/com/rayh/XCodeBuilder/config.jelly
http://jenkins-ci.org/commit/xcode-plugin/5d4f52127cccbe60a52121083f70f9dc29e7e73b
Log:
Merge pull request #86 from lampietti/xcode9
add xcode9 new signing support JENKINS-45509
Compare: https://github.com/jenkinsci/xcode-plugin/compare/7172a7c67279...5d4f52127ccc
scm_issue_link so, now we should be able to use jenkins to create our build successfully, right?
scm_issue_link what version of jenkins will have this change? nguyenhoang jamesrantmedia
ronakpatel786 I haven't used Jenkins plugins for iOS builds so have no idea about this.
ronakpatel786 , Currently kazuhidet 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:
$ /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?
-allowProvisioningUpdates seems to be an option added with xcode 9
https://www.developerinsider.in/whats-new-in-xcode-9
kapten_perk: Which xcode version do you use?
stephanwezelps: The machine runs Xcode 7.3.1. That seems to be the last version of Xcode from the App store in El Captain.
I am facing the same issue.