Jenkins can not export app-store ipa - ios

The ARCHIVE Process is always successful, but not the EXPORT process.
Here is the thing, when the export type is development, it always success.
But when I change the export type to app-store, it went wrong.
And here is the error message.
10:01:52 ** ARCHIVE SUCCEEDED **
10:01:52
10:01:52 Cleaning up previously generated .ipa files
10:01:52 Cleaning up previously generated .dSYM.zip files
10:01:52 Packaging IPA
10:01:52 [XCodeProj] $ /usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleVersion" /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/XCodeProj/build/Release-iphoneos/Unity-iPhone.xcarchive/Info.plist
10:01:52 [XCodeProj] $ /usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleShortVersionString" /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/XCodeProj/build/Release-iphoneos/Unity-iPhone.xcarchive/Info.plist
10:01:52 Packaging Unity-iPhone.xcarchive => /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/artifacts/jenkins-Release-app-store-364.ipa
10:01:52 [XCodeProj] $ /usr/bin/xcodebuild -exportArchive -archivePath /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/XCodeProj/build/Release-iphoneos/Unity-iPhone.xcarchive -exportPath /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/artifacts -exportOptionsPlist /Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/artifacts/app-store2477P575MMExport.plist
10:01:52 2018-01-09 10:01:52.598 xcodebuild[3570:174459] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/2w/320q_j1s5x10tmvq2rmwgx3c000086/T/Unity-iPhone_2018-01-09_10-01-52.597.xcdistributionlogs'.
10:01:53 2018-01-09 10:01:53.800 xcodebuild[3570:174459] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7f89ce77b200>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed." UserInfo={NSLocalizedDescription=Locating signing assets failed., IDEDistributionSigningAssetStepUnderlyingErrors=(
10:01:53 "Error Domain=IDEProfileLocatorErrorDomain Code=1 \"No profiles for 'com.pantheon.artopia' were found\" UserInfo={NSLocalizedDescription=No profiles for 'com.pantheon.artopia' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS App Store provisioning profiles matching 'com.pantheon.artopia'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.}"
10:01:53 )}
10:01:53 error: exportArchive: No profiles for 'com.pantheon.artopia' were found
10:01:53
10:01:53 Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.pantheon.artopia' were found" UserInfo={NSLocalizedDescription=No profiles for 'com.pantheon.artopia' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS App Store provisioning profiles matching 'com.pantheon.artopia'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.}
10:01:53
10:01:53 ** EXPORT FAILED **
The error message said that I don't have a proper provision profile for my app.
But I just make two app-store distribution profile for my app, one for com.pantheon.artopia, and one for wildcard.
And I actually download them and copy them to jenkins's provision profiles folder.
It also suggest to put -allowProvisioningUpdates to xcodebuild, and I actually did it.
But the bas thing is -allowProvisioningUpdates only passed to the archive step, but not to the export step.
So how could I solve this, I need your suggestions.
My jenkins settings are:

In the "General build settings" of the Xcode Plugin, just deselect step "Pack application, build and sign .ipa?", and add one "Execute Shell" step.
The shell script is simple:
/usr/bin/xcodebuild -exportArchive -archivePath "/Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/XCodeProj/build/Debug-iphoneos/Unity-iPhone.xcarchive" -exportPath "/Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/artifacts" -exportOptionsPlist "/Users/Shared/Jenkins/Home/workspace/artopia/artopia-iOS/exportoptions/ExportOptions-"${ExportType}".plist" -allowProvisioningUpdates
The only thing you should provide is exportoptions.plist, which you can find one in your own Xcode Export directory.
You can find more information in https://github.com/fastlane/fastlane/issues/9589

Related

Not able to create IPA using xcodebuild command through jenkins shell script

I am trying to create an IPA file using below command on Jenkin
xcodebuild -exportArchive -archivePath export/MySampleApp.xcarchive -exportPath export/ -exportOptionsPlist export/export_options.plist
But it gives me error
+ xcodebuild -exportArchive -archivePath export/MySampleApp.xcarchive -exportPath export/ -exportOptionsPlist export/export_options.plist
2018-06-19 19:16:07.324 xcodebuild[81214:2060182] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/y5/1qdx7j6j2tdb1j6g3vvg_xww0000gn/T/MySampleApp_2018-06-19_19-16-07.323.xcdistributionlogs'.
2018-06-19 19:17:20.872 xcodebuild[81214:2060182] [MT] IDEDistribution: Step failed: <IDEDistributionPackagingStep: 0x7ff2b080be50>: Error Domain=IDEDistributionPipelineErrorDomain Code=0 "Code signing "libswiftCore.dylib" failed." UserInfo={NSLocalizedDescription=Code signing "libswiftCore.dylib" failed., NSLocalizedRecoverySuggestion=View distribution logs for more information.}
error: exportArchive: Code signing "libswiftCore.dylib" failed.
Error Domain=IDEDistributionPipelineErrorDomain Code=0 "Code signing "libswiftCore.dylib" failed." UserInfo={NSLocalizedDescription=Code signing "libswiftCore.dylib" failed., NSLocalizedRecoverySuggestion=View distribution logs for more information.}
** EXPORT FAILED **
I was able to create an archive file using below command
xcodebuild -scheme "MySampleApp" -sdk iphoneos -target MySampleApp -destination "generic/platform=iOS" -archivePath export/MySampleApp.xcarchive archive DEVELOPMENT_TEAM="QPG8EMUULT" PROVISIONING_PROFILE="efb8da47-3b87-4880-82e8-4967167bb2d3" CODE_SIGNING_REQUIRED=NO
Can anyone please let me know what could be the issue ?
Keychain was locked on Jenkin server thats why it was not able to code sign.
Unlocked it with below command before xcodebuild command
security unlock-keychain -p yourPassword
Now its working good.
I met the problem when :
xcodebuild archive using Xcode 10
xcode-select to Xcode 9
try to run xcodebuild -exportArchive
so I xcode-select to Xcode 10 and problem solved

Xcode 9.2 Archive Succeed but unable to Export IPA

I am trying to continuous integrate for an Enterprise IOS Build for AdhocProd. Using below command for Build and Archive .
Build Command:
/usr/bin/xcodebuild -workspace "Project.xcworkspace" -scheme
"ProjectiOSPROD" -archivePath build/ProjectiOS -configuration Release
archive CODE_SIGN_STYLE=Manual
PROVISIONING_PROFILE=”CompanyNameProdAdhocDistribution”
CODE_SIGNING_IDENTITY="iPhone Developer: Build Machine(XXXXXX)"
PRODUCT_BUNDLE_IDENTIFIER="com.Companyname.prod.ProjectiOS"
OUTPUT:
** ARCHIVE SUCCEEDED **
Export Command:
/usr/bin/xcodebuild -exportArchive -archivePath "build/ProjectiOS.xcarchive" -exportPath "build/ProjectiOS.ipa" -exportOptionsPlist"../../ExportOptions.plist"
This Plist is ExportOptions.Plist taken from the xcode IDE. and using it for jenkins work space
Output:
error: exportArchive: SDWebImage.framework does not support provisioning profiles.
Error Domain=IDEProvisioningErrorDomain Code=10 "SDWebImage.framework does not support provisioning profiles." UserInfo={NSLocalizedDescription=SDWebImage.framework does not support provisioning profiles., NSLocalizedRecoverySuggestion=SDWebImage.framework does not support provisioning profiles, but provisioning profile CompanyNameProdAdhocDistribution has been manually specified. Remove this item from the "provisioningProfiles" dictionary in your Export Options property list.}
error: exportArchive: Stripe.framework does not support provisioning profiles.
Error Domain=IDEProvisioningErrorDomain Code=10 "Stripe.framework does not support provisioning profiles." UserInfo={NSLocalizedDescription=Stripe.framework does not support provisioning profiles., NSLocalizedRecoverySuggestion=Stripe.framework does not support provisioning profiles, but provisioning profile CompanyNameProdAdhocDistribution has been manually specified. Remove this item from the "provisioningProfiles" dictionary in your Export Options property list.}
provisioningProfiles dictionary is already present in Property list. If i removed this it says add this to Property list.
Any Suggestions would be greatly Appreciated.
You have to generate and export the IPA manually with Xcode9.2. This will create a file name ExportOptions.plist in the exported folder.
Copy that file to workspace root folder.
Write below command in Execute shell.
xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/YourProject.xcarchive -exportPath ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/archive -exportOptionsPlist ${WORKSPACE}/ExportOptions.plist

Getting IOS development build error

Development build get the following error during export, it shows that archive succeeded. Also the app store distribution build passes. I used the cert tool to generate all certs for this.
The full build log is here:
Build log
Here is the messages that look like the cause of the failure:
** ARCHIVE SUCCEEDED **
Executing: echo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist
Executing: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -exportArchive -archivePath rvgame.xcarchive -exportPath /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4175955742863989776xxx/result -exportOptionsPlist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/export4912377426492049316.plist -verbose PROVISIONING_PROFILE=4b697edf-96fe-4b7a-ae88-07eaa148026f CODE_SIGN_IDENTITY=iPhone Developer: samuel lotti (V8JNGG63WU) KEYCHAIN=/Users/administrator/Library/Keychains/temp1513260206451.keychain CODE_SIGN_ENTITLEMENTS=/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/Entitlements4983206492678257794.plist 2017-12-14 08:05:38.785 xcodebuild[42364:31715511] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/rvgame_2017-12-14_08-05-38.784.xcdistributionlogs'.
2017-12-14 08:05:38.825 xcodebuild[42364:31715511] [MT] DeveloperPortal: Using pre-existing current store at URL (file:///Users/administrator/Library/Developer/Xcode/DeveloperPortal%207.3.1.db).
2017-12-14 08:05:59.053 xcodebuild[42364:31715511] [MT] IDEDistribution: Step failed: : Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo={NSLocalizedDescription=No applicable devices found.}
error: exportArchive: No applicable devices found.
Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo={NSLocalizedDescription=No applicable devices found.}
** EXPORT FAILED **
Not sure how to fix this.
This was a problem with new Xcode requirements on static libraries. The Admob and Flurry static libs were compiled with an older version of Xcode which didn't include LC_VERSION_MIN_IPHONEOS run commands, and ipatool now crashes if it encounters a library that doesn't include this.
I have updated both the Admob and the Flurry cn1libs to use Cocoapods instead of the static library directly, and this will fix the issue. These will be available in Codename One Settings after the next server update (this week). If you need them before then, you can download and install the cn1libs directly:
https://github.com/codenameone/CodenameOneLibs/raw/master/cn1libs/CN1Flurry.cn1lib
https://github.com/codenameone/CodenameOneLibs/raw/master/cn1libs/AdmobFullScreen.cn1lib
I have also made some changes on the build server to add a more descriptive error message when it detects this scenario. That will also be updated in the next build server update.

Exporting xcarchive and IPA in xcode 6.4

I want to make build scripts for my app to export xcarchive and ipa files.
I used following command to export xcarchive:
xcodebuild -scheme myscheme archive -archivePath path/appname.xcarchive
Which gave me an xcarchive file and I used following to export IPA file:
xcodebuild -exportArchive -exportFormat IPA -exportProvisioningProfile *** -archivePath path/appname.xcarchive -exportPath path/appname.ipa
And I got following error regardless of what I typed in front of exportProvisioningProfile.
no provisioning profile matches ***
** EXPORT FAILED **
What should I write insted of *** in front of exportProvisioningProfile?
The name of the provisioning profile. This is the same name as seen on the page (https://developer.apple.com/account/ios/profile/profileList.action). If you have spaces in that name you need to write the name with quotes. E.g.
xcodebuild -exportArchive -exportFormat IPA -archivePath
MyMobileApp.xcarchive -exportPath MyMobileApp.ipa
-exportProvisioningProfile 'MyMobileApp Distribution Profile'
It may also be that you have not downloaded the provisioning profile, try re-downloading it and opening it with Xcode to install it in the correct location.

xcodebuild archive fails ITMS validation

Our app has a watchkit app + extension. Archives from XCode IDE always pass iTunes store validation. However archives generated via xcodebuild command tools (Xcode 6.4; Build version 6E35b) fail this validation with the following errors:
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/DodoExtension.appex/DodoExtension'."
ERROR ITMS-90164: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. According to the provisioning profile, the bundle contains a key value that is not allowed: '##########.###.##########.######' for the key 'application-identifier' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension'"
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension'."
ERROR ITMS-90046: "Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported on iOS. Specifically, value '##########.###.##########.######' for key 'application-identifier' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitExtension' is not supported. This value should be a string starting with your TEAMID, followed by a dot '.', followed by the bundle identifier."
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'aps-environment' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitApp.app/TheDodoWatchKitApp'."
ERROR ITMS-90163: "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'com.apple.security.application-groups' in 'Payload/TheDodo.app/PlugIns/TheDodoWatchKitExtension.appex/TheDodoWatchKitApp.app/TheDodoWatchKitApp'."
The Makefile to archive and export looks something like this:
/usr/bin/xcodebuild -verbose -verbose -workspace 'rebelmouse.xcworkspace' -scheme TheDodo -configuration "App Store" -sdk 'iphoneos' -archivePath /tmp/TheDodo.xcarchive -derivedDataPath /tmp/ROJECT.Ji9vwyH0 APPLICATION_BUILD_VERSION=2456 archive
/usr/bin/xcodebuild -exportArchive -exportFormat ipa -archivePath /tmp/TheDodo.xcarchive -exportPath /tmp/TheDodo.ipa -exportWithOriginalSigningIdentity
Any suggestion / help is very appreciated. Thanks in advance.
Answering this in case anyone else is stuck in the same boat.
With Xcode 7.0 the xcodebuild acquired a new command line option to export archive namely the exportOptionsPlist , this takes a full path to a plist that configures the archive.
You no longer need to set the -exportFormat
xcodebuild --help lists the details of the plist.
For enterprise builds I use this plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>
</dict>
</plist>
For App Store builds replace replace enterprise with app-store.
tell xcodebuild the name of the provisioning profile to use instead of having it 'auto-search' it:
xcodebuild -exportArchive -exportFormat ipa -archivePath "FOLD/FILE.xcarchive" -exportPath "FOLD/FILE.ipa" -exportProvisioningProfile "NAME" > /dev/null || exit 1

Resources