xcodebuilds exportArchive fails to build ipa for store

In our Jenkins build system we build an archive and then from that we generate an ipa to be uploaded to the store.


xcodebuild -exportArchive -archivePath myApp.xcarchive -exportOptionsPlist exportOptions.plist -exportPath . PROVISIONING_PROFILE=fdd0caeb-58fb-41df-a5e8-e5e9bd1f95c9 "OTHER_CODE_SIGN_FLAGS=--keychain /Users/me/Library/Keychains/Buildsystem"


But it is failing with:


2016-10-06 23:29:23.438 xcodebuild[87720:8494157] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/yd/l_8k4cn91kjc9r853crzz98m0000gn/T/MyApp_2016-10-06_23-29-23.437.xcdistributionlogs'.

2016-10-06 23:29:23.888 xcodebuild[87720:8494157] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7ff74bbf9de0>: Error Domain=IDEDistributionErrorDomain Code=1 "The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)"

error: exportArchive: The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)


Error Domain=IDEDistributionErrorDomain Code=1 "The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)"


** EXPORT FAILED **


I can copy the archive and exportOptions.plist to my machine and it will work.


I suspect it has something to do with the code signing identity.


I notice if I take the .p12 file and install the identity in the keychain on the jenkins build machine:

security import AP_Store.p12 -k /Users/me/Library/Keychains/Buildsystem -P ******* -T /usr/bin/codesign


then run:

security find-identity


I get:

1) 71497439A2987BC6830DF2E4879DBD3A5F1B2857 "iPhone Distribution: xxxxx (xxxxxxxxx)" (CSSMERR_TP_CERT_EXPIRED)


But the certificate has not expired and if I install it on my own machine it is OK.


Does anybody have a clue what is going on here?


I am not sure if it is relevant but the Jenkins build machine is a virtual machine.

Replies

I found the problem, "Apple Worldwide Developer Relations Certification Authority" had expired.

Another thing that can lead to errors such as:


2016-10-11 11:41:11.780 xcodebuild[87463:15799133] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7f84732f0c80>: Error Domain=IDEDistributionErrorDomain Code=1 "(null)"

error: exportArchive: The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)


is if you have an incorrect team ID in your exportOptions.plist file.