Xcode IOS build failing with random errors but also succeed after 1 or 2 retries

591 Views Asked by At

Currently we are in a very strange situation with our Xcode build for an IOS App. Archiving our app with

xcodebuild -workspace App.xcworkspace -scheme AppName -sdk iphoneos clean archive -archivePath archive/AppName.xcarchive

is working flawless. However, pushing this archive to Apple with the following command:

xcodebuild -exportArchive -archivePath App/archive/AppName.xcarchive -exportOptionsPlist ExportOptionsAppStore.plist -exportPath App/archive/AppName -allowProvisioningUpdates

and belonging ExportOptionsAppStore.plist

<?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>destination</key>
    <string>upload</string>
    <key>method</key>
    <string>app-store</string>
    <key>signingStyle</key>
    <string>automatic</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>our-team-id</string>
    <key>uploadSymbols</key>
    <true/>
        <key>manageAppVersionAndBuildNumber</key>
        <false/>
   </dict>
</plist>

Is most of the time failing with random errors, and after 2 or 3 retries it succeed. But sometimes it succeed the first time. There is not logical explanation for this.

We are running this build in our GitLab CI (our runner is a Macbook Air), but running this directly on the MacBook Air resulting in the same error.

The random errors are:

2023-02-28 09:27:47.035 xcodebuild[21915:7489205] Starting upload
2023-02-28 09:27:47.630 xcodebuild[21915:7489206] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:27:47.631 xcodebuild[21915:7489206] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:27:47.633 xcodebuild[21915:7489206] Progress 0%: Preparing to upload ‘AppName.ipa’…
2023-02-28 09:27:47.671 xcodebuild[21915:7489206] Progress 0%: Analyzing package…
2023-02-28 09:27:57.919 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Will re-try.
2023-02-28 09:28:00.251 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Will re-try.
2023-02-28 09:28:02.593 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Giving up.
2023-02-28 09:28:02.792 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Will re-try.
2023-02-28 09:28:05.247 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Will re-try.
2023-02-28 09:28:07.577 xcodebuild[21915:7489211] Progress 0%: Failed to retrieve upload operations. Giving up.
2023-02-28 09:28:07.580 xcodebuild[21915:7489211] Progress 0%: Collecting package attributes…
2023-02-28 09:28:07.582 xcodebuild[21915:7489211] Progress 0%: Requesting upload instructions from App Store Connect…
2023-02-28 09:28:07.784 xcodebuild[21915:7489211] Progress 0%: Upload failed.
The provided entity includes a relationship with an invalid value
'' is not a valid id for the relationship 'build' (ID: 00a00ab0-a0f0-0000-a00b-0000c0000ecf)
error: exportArchive: The provided entity includes a relationship with an invalid value. '' is not a valid id for the relationship 'build' (ID: 00a00ab0-a0f0-0000-a00b-0000c0000ecf).
Error Domain=ContentDelivery Code=409 "error: The provided entity includes a relationship with an invalid value. '' is not a valid id for the relationship 'build' (ID: 00a00ab0-a0f0-0000-a00b-0000c0000ecf)." UserInfo={NSLocalizedDescription=error: The provided entity includes a relationship with an invalid value. '' is not a valid id for the relationship 'build' (ID: 00a00ab0-a0f0-0000-a00b-0000c0000ecf).}
** EXPORT FAILED **
2023-02-28 09:28:59.848 xcodebuild[22503:7491133] Starting upload
2023-02-28 09:29:00.452 xcodebuild[22503:7491178] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:29:00.454 xcodebuild[22503:7491178] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:29:00.456 xcodebuild[22503:7491178] Progress 0%: Preparing to upload ‘AppName.ip’…
2023-02-28 09:29:00.461 xcodebuild[22503:7491178] Progress 0%: Upload failed.
Failed to upload package ‘AppName.ipa’.
You must provide the Apple ID of the package.
error: exportArchive: Failed to upload package ‘AppName.ipa’. You must provide the Apple ID of the package.
Error Domain=ContentDelivery Code=-19211 "error: Failed to upload package ‘AppName.ipa’. You must provide the Apple ID of the package." UserInfo={NSLocalizedDescription=error: Failed to upload package ‘AppName.ipa’. You must provide the Apple ID of the package.}
error: exportArchive: Failed to upload package ‘AppName.ipa’. You must provide the Public Provider ID for the package.
Error Domain=ContentDelivery Code=-19210 "error: Failed to upload package ‘AppName.ipa’. You must provide the Public Provider ID for the package." UserInfo={NSLocalizedDescription=error: Failed to upload package ‘AppName.ipa’. You must provide the Public Provider ID for the package.}
** EXPORT FAILED **
2023-02-28 11:25:43.992 xcodebuild[42596:7578942] Starting upload
2023-02-28 11:25:44.665 xcodebuild[42596:7578954] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 11:25:44.667 xcodebuild[42596:7578954] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 11:25:44.669 xcodebuild[42596:7578945] Progress 0%: Preparing to upload ‘AppName.ipa’…
2023-02-28 11:25:44.710 xcodebuild[42596:7578945] Progress 0%: Analyzing package…
2023-02-28 11:25:54.060 xcodebuild[42596:7578958] Progress 0%: Failed to retrieve upload operations. Will re-try.
2023-02-28 11:25:56.642 xcodebuild[42596:7578958] Progress 0%: Sending analysis to App Store Connect…
2023-02-28 11:25:57.588 xcodebuild[42596:7578958] Progress 0%: Waiting for App Store Connect analysis response…
2023-02-28 11:26:03.758 xcodebuild[42596:7578999] Progress 0%: Sending SPI analysis to App Store Connect…
2023-02-28 11:26:04.095 xcodebuild[42596:7578999] Progress 0%: Waiting for App Store Connect SPI analysis response…
2023-02-28 11:26:14.682 xcodebuild[42596:7578958] Progress 0%: Collecting package attributes…
2023-02-28 11:26:14.684 xcodebuild[42596:7578958] Progress 0%: Requesting upload instructions from App Store Connect…
2023-02-28 11:26:14.896 xcodebuild[42596:7578958] Progress 0%: Upload failed.
Account credentials have expired.
error: exportArchive: Account credentials have expired. Open Xcode's Accounts preference pane, sign in to your account, and try again.
Error Domain=DVTITunesSoftwareServiceFoundation.AuthContextDelegateError Code=0 "error: Account credentials have expired. Open Xcode's Accounts preference pane, sign in to your account, and try again." UserInfo={NSLocalizedDescription=error: Account credentials have expired. Open Xcode's Accounts preference pane, sign in to your account, and try again.}
** EXPORT FAILED **
error: exportArchive: The operation couldn’t be completed. (IDEFoundation.DistributionAppRecordProviderError error 3.)
IDEFoundation.DistributionAppRecordProviderError.appRecordRequestFailed(Unexpected Status Code: 401
---
Headers:
'Content-Length': '350'
'x-frame-options': 'SAMEORIGIN'
'x-content-type-options': 'nosniff'
'x-content-security-policy': 'script-src 'self' *.apple.com'
'Server': 'daiquiri/3.0.0'
'Date': 'Tue, 28 Feb 2023 15:06:40 GMT'
'x-apple-jingle-correlation-key': 'LUQFRMBPSO000KOQXKQZY0QUJQ'
'x-daiquiri-instance': 'daiquiri:38493001:pv0p00it-hyhk00000000:0000:00RELEASE00:daiquiri-amp-all-shared-ext-001-pv'
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload'
'Content-Type': 'application/json'
'x-xss-protection': '1; mode=block'
---
Data:
{
    "errors": [{
        "status": "401",
        "code": "NOT_AUTHORIZED",
        "title": "Authentication credentials are missing or invalid.",
        "detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"
    }]
}
---
)

And of course the success message.

2023-02-28 09:30:15.614 xcodebuild[22818:7492485] Starting upload
2023-02-28 09:30:16.210 xcodebuild[22818:7492500] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:30:16.212 xcodebuild[22818:7492500] Progress 0%: Making copy of ‘AppName.ipa’…
2023-02-28 09:30:16.214 xcodebuild[22818:7492500] Progress 0%: Preparing to upload ‘AppName.ipa’…
2023-02-28 09:30:16.254 xcodebuild[22818:7492500] Progress 0%: Analyzing package…
2023-02-28 09:30:26.137 xcodebuild[22818:7492500] Progress 0%: Sending analysis to App Store Connect…
2023-02-28 09:30:27.160 xcodebuild[22818:7492500] Progress 0%: Waiting for App Store Connect analysis response…
2023-02-28 09:30:32.656 xcodebuild[22818:7492500] Progress 0%: Sending SPI analysis to App Store Connect…
2023-02-28 09:30:32.963 xcodebuild[22818:7492500] Progress 0%: Waiting for App Store Connect SPI analysis response…
2023-02-28 09:30:43.861 xcodebuild[22818:7492494] Progress 0%: Collecting package attributes…
2023-02-28 09:30:43.863 xcodebuild[22818:7493316] Progress 0%: Requesting upload instructions from App Store Connect…
2023-02-28 09:30:44.186 xcodebuild[22818:7493316] Progress 0%: Preparing file for upload to App Store Connect…
2023-02-28 09:30:44.196 xcodebuild[22818:7493316] Progress 0%: Preparing file for upload to App Store Connect…
2023-02-28 09:30:44.259 xcodebuild[22818:7493316] Progress 0%: Uploading to App Store Connect…
2023-02-28 09:30:44.349 xcodebuild[22818:7493316] Progress 22%: Uploading to App Store Connect…
2023-02-28 09:30:44.351 xcodebuild[22818:7493316] Progress 22%: Uploading to App Store Connect…
2023-02-28 09:30:45.089 xcodebuild[22818:7493316] Progress 78%: Uploading to App Store Connect…
2023-02-28 09:30:45.090 xcodebuild[22818:7493316] Progress 78%: Uploading to App Store Connect…
2023-02-28 09:30:50.273 xcodebuild[22818:7493316] Progress 89%: Uploading to App Store Connect…
2023-02-28 09:30:50.274 xcodebuild[22818:7493316] Progress 89%: Uploading to App Store Connect…
2023-02-28 09:30:52.137 xcodebuild[22818:7493316] Progress 100%: Uploading to App Store Connect…
2023-02-28 09:30:52.138 xcodebuild[22818:7493316] Progress 100%: Uploading to App Store Connect…
2023-02-28 09:30:54.769 xcodebuild[22818:7493316] Progress 100%: Checking build state…
2023-02-28 09:30:54.771 xcodebuild[22818:7493316] Progress 100%: Completing upload…
2023-02-28 09:30:55.944 xcodebuild[22818:7493316] Progress 100%: Waiting for package to begin processing…
2023-02-28 09:30:56.141 xcodebuild[22818:7493316] Progress 100%: Uploaded package is processing.
2023-02-28 09:30:56.555 xcodebuild[22818:7493316] Progress 100%: Upload succeeded.
Uploaded AppName
** EXPORT SUCCEEDED **

Xcode was running on version 14.1 and we did upgrade Xcode to 14.2 without any luck. Also we logged out our logged in user, but even that had no luck.

But the point here is, it succeed after 2 or 3 retries or it succeed the first time.

What can we do to fix this? Or is anyone that had the same issue?

*note: we changed our app name in this post to AppName. We are using a different AppName of course. *

Using a manual created certificated and provision profile seems to work out of the box. So my feeling is that using an account is somehow buggy...?

0

There are 0 best solutions below