1
xcodebuild \
  -exportArchive -verbose \
  -sdk iphoneos \
  -archivePath XYZProject.xcarchive \
  -exportOptionsPlist $RUNNER_TEMP/ExportOptions.plist \
  -exportPath "" \
  -authenticationKeyIssuerID ${{ secrets.APPSTORE_ISSUER_ID }} \
  -authenticationKeyID ${{ secrets.APPSTORE_API_KEY_ID }} \
  -authenticationKeyPath $RUNNER_TEMP/AuthKey_${{ secrets.APPSTORE_API_KEY_ID }}.p8

Uploading build to appstore connect fails with the error:

error: exportArchive: Failed to log in.

Error Domain=IDEDistributionErrorDomain Code=10 "Failed to log in." UserInfo={IDEDistributionErrorsAccountIssues=(
), NSLocalizedDescription=Failed to log in., NSLocalizedRecoverySuggestion=App Store Connect access for “*******” is required. Ensure that your Apple ID account usernames and passwords are correct in the Accounts preference pane.}

If I login to Xcode with the appleId, this just works fine but that is why I use authenticationKeyID, authenticationKeyIssuerID, authenticationKeyPath to authenticate.

ExportOptions.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>manageAppVersionAndBuildNumber</key>
    <true/>
    <key>method</key>
    <string>app-store</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.my.bundle.id</key>
        <string>AppName - PROD</string>
    </dict>
    <key>signingCertificate</key>
    <string>Apple Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>teamID</string>
    <key>uploadSymbols</key>
    <true/>
</dict>
</plist>

Any idea what could be the issue here?

Please note the key has developer role access to app store connect.

Edit : Using an admin key also doesn't solve the issue

HangarRash
  • 7,314
  • 5
  • 5
  • 32
ajw
  • 2,568
  • 23
  • 27
  • Does this command work locally from the terminal with credentials set in env vars? – Azeem Jul 05 '23 at 05:37
  • The quotes here `-exportPath “”` don't look right. Maybe, some copy/paste issue. Also, single quote `'${{...}}'` and double quote shell variables `"$VAR"`. In your case, for arguments including shell variables, you should use double quotes i.e. `"$RUNNER_TEMP/AuthKey_${{ secrets.APPSTORE_API_KEY_ID }}.p8"`. But, it shouldn't be an issue if all those values don't have space in them and are one single continuous value. – Azeem Jul 05 '23 at 05:42
  • @Azeem This command works fine locally when I logged in to Xcode with my appleId and it directly exports the build to Testflight. I hardcoded the credentials and tested them. Also, I added the quotes as you suggested but there is no difference. – ajw Jul 05 '23 at 05:57
  • Are you using a self-hosted runner or GHA-hosted one? – Azeem Jul 05 '23 at 06:02
  • Have you looked at this? https://discussions.apple.com/thread/254448401 – Azeem Jul 05 '23 at 06:04
  • Self hosted runner. – ajw Jul 05 '23 at 06:19
  • Did you try and run this command from terminal on that self-hosted runner? – Azeem Jul 05 '23 at 06:21
  • No. I just tried with the local terminal yet. Do you think that will make any difference? – ajw Jul 05 '23 at 06:24
  • Yes, it should be tested there too. If there's a difference then you can figure that out and make it similar to your local machine. Once that is done, your GHA workflow should work fine without any change. – Azeem Jul 05 '23 at 06:32
  • 1
    @Azeem I get the same error in the self-hosted runner too. – ajw Jul 05 '23 at 07:34
  • Is the Xcode version the same on your local and self-hosted runner? Have you configured the certificate on your self-hosted runner same as your local machine? – Azeem Jul 05 '23 at 07:42
  • This answer looks relevant: https://stackoverflow.com/a/19856005/7670262 – Azeem Jul 05 '23 at 07:44

1 Answers1

0

Even with developer role access, you may need to enable Access to Certificates, Identifiers & Profiles in App Store Connect for your user (see screenshot).

App Store Connect

Patrick
  • 11
  • 3