XCodeBuild (Xcode16) account verification error

Our CI process uses XcodeBuild tools. It used to work very well. The shell code is as follows:

step 1 "++++++++++++++++clean++++++++++++++++"
xcodebuild clean -workspace ${WORKSPACE_NAME}.xcworkspace \
                 -scheme ${SCHEME_NAME} \
                 -configuration ${configuration}
                 
step 2  "+++++++++++++++++archive+++++++++++++++++"
xcodebuild archive -workspace ${WORKSPACE_NAME}.xcworkspace \
                   -scheme ${SCHEME_NAME} \
                   -configuration ${configuration} \
                   -archivePath ${ARCHIVE_PATH}
                   -allowProvisioningUpdates YES
                  

step 3 "+++++++++++++++++ipa+++++++++++++++++"
xcodebuild -exportArchive \
           -archivePath ${ARCHIVE_PATH} \
           -exportPath "${IPA_PATH}" \
           -exportOptionsPlist ${EXPORT_METHOD_PLIST_PATH} \
           -allowProvisioningUpdates YES

However, there is a problem after upgrading Xcode16. When it is executed to the third step, there will be an error in the error account. Even if I delete my developer account, and then log in again, the same error will still be reported. The specific error is as follows:

** ARCHIVE SUCCEEDED **

/var/folders/ch/1mvd9gz11cn8zy9h254qz2600000gn/T/jenkins6531487518988891980.sh: line 194: -allowProvisioningUpdates: command not found
+++++++++++++++++ipa+++++++++++++++++
2024-10-10 18:20:35.630 xcodebuild[58030:2528109] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path "/var/folders/ch/1mvd9gz11cn8zy9h254qz2600000gn/T/xxxxxx_2024-10-10_18-20-35.623.xcdistributionlogs".
2024-10-10 18:20:35.724 xcodebuild[58030:2528191]  DVTDeveloperAccountManager: Failed to load credentials for xxxxxxxxxx: Error Domain=DVTDeveloperAccountCredentialsError Code=0 "Invalid credentials in keychain for xxxxxxxxxx, missing Xcode-Username" UserInfo={NSLocalizedDescription=Invalid credentials in keychain for xxxxxxxxxx, missing Xcode-Username}
2024-10-10 18:20:35.733 xcodebuild[58030:2528191]  DVTDeveloperAccountManager: Failed to load credentials for F38D3CD7-C794-4F88-93ED-4FDDD8EDF72B: Error Domain=DVTDeveloperAccountCredentialsError Code=0 "Invalid credentials in keychain for F38D3CD7-C794-4F88-93ED-4FDDD8EDF72B, missing Xcode-Username" UserInfo={NSLocalizedDescription=Invalid credentials in keychain for F38D3CD7-C794-4F88-93ED-4FDDD8EDF72B, missing Xcode-Username}
2024-10-10 18:20:35.742 xcodebuild[58030:2528191]  DVTDeveloperAccountManager: Failed to load credentials for ***@***.com: Error Domain=DVTDeveloperAccountCredentialsError Code=0 "Invalid credentials in keychain for ***@***.com, missing Xcode-Token" UserInfo={NSLocalizedDescription=Invalid credentials in keychain for ***@***.com, missing Xcode-Token}
2024-10-10 18:20:40.521 xcodebuild[58030:2528195]  IDEDistribution: Failed to log in with account "(null)" while checking for an App Store Connect account (Error Domain=DVTServicesAccountBasedSessionErrorDomain Code=0 "Unable to log in with account ''." UserInfo={NSLocalizedFailureReason=Unable to log in with account ''., NSLocalizedRecoverySuggestion=The login details for account '' were rejected., DVTDeveloperAccountErrorAccount=<DVTAppleIDBasedDeveloperAccount: 0x600002d92a80; username=''>, NSUnderlyingError=0x600002758ab0 {Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload={
    creationTimestamp = "2024-10-10T10:20:40Z";
    httpCode = 200;
    protocolVersion = QH65B2;
    requestUrl = "https://developerservices2.apple.com/services/QH65B2/viewDeveloper.action";
    responseId = "12827504-3d86-4601-bcf7-efc0dccb0655";
    resultCode = 1100;
    resultString = "Your session has expired. Please log in.";
    userLocale = "en_US";
    userString = "Your session has expired. Please log in.";
}, NSLocalizedDescription=Your session has expired. Please log in.}}})
2024-10-10 18:20:40.760 xcodebuild[58030:2528195]  IDEDistribution: Failed to log in with account "(null)" while checking for an App Store Connect account (Error Domain=DVTServicesAccountBasedSessionErrorDomain Code=0 "Unable to log in with account ''." UserInfo={NSLocalizedFailureReason=Unable to log in with account ''., NSLocalizedRecoverySuggestion=The login details for account '' were rejected., DVTDeveloperAccountErrorAccount=<DVTAppleIDBasedDeveloperAccount: 0x600002de7e80; username=''>, NSUnderlyingError=0x6000027842d0 {Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload={
    creationTimestamp = "2024-10-10T10:20:40Z";
    httpCode = 200;
    protocolVersion = QH65B2;
    requestUrl = "https://developerservices2.apple.com/services/QH65B2/viewDeveloper.action";
    responseId = "e49c99d0-861c-4d80-9cd7-8430bcdfa6a6";
    resultCode = 1100;
    resultString = "Your session has expired. Please log in.";
    userLocale = "en_US";
    userString = "Your session has expired. Please log in.";
}, NSLocalizedDescription=Your session has expired. Please log in.}}})
2024-10-10 18:20:41.053 xcodebuild[58030:2528195]  IDEDistribution: Failed to log in with account "(null)" while checking for an App Store Connect account (Error Domain=DVTServicesAccountBasedSessionErrorDomain Code=0 "Unable to log in with account '***@***.com'." UserInfo={NSLocalizedFailureReason=Unable to log in with account '***@***.com'., NSLocalizedRecoverySuggestion=The login details for account '***@***.com' were rejected., DVTDeveloperAccountErrorAccount=<DVTAppleIDBasedDeveloperAccount: 0x600002de7b80; username='***@***.com'>, NSUnderlyingError=0x6000027a4780 {Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload={
    creationTimestamp = "2024-10-10T10:20:41Z";
    httpCode = 200;
    protocolVersion = QH65B2;
    requestUrl = "https://developerservices2.apple.com/services/QH65B2/viewDeveloper.action";
    responseId = "5819c66e-bd35-4af3-ae6a-0e66193fa2bb";
    resultCode = 1100;
    resultString = "Your session has expired. Please log in.";
    userLocale = "en_US";
    userString = "Your session has expired. Please log in.";
}, NSLocalizedDescription=Your session has expired. Please log in.}}})
error: exportArchive The operation couldn’t be completed. Unable to log in with account ''.

error: exportArchive Provisioning profile "iOS Team Store Provisioning Profile: com.xxxx.xxxxx" doesn't include signing certificate "Apple Distribution: xxxxxxxxxxx".

** EXPORT FAILED **

At the same time, a lot of blank error accounts will appear in Xcode-Settings-ACCOUNT. The screenshots are as follows

How should I solve this problem, I look forward to your reply very much

Answered by DTS Engineer in 808960022

@AdamShi , @sepccom Additionally, you can workaround this issue by running the following command in Terminal:

defaults delete com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists

"Your session has expired. Please log in.";

When logging into Xcode Accounts setting, you'll need to re-authenticate from time to time.

xcodebuild -exportArchive \

       -archivePath ${ARCHIVE_PATH} \
       -exportPath "${IPA_PATH}" \
       -exportOptionsPlist ${EXPORT_METHOD_PLIST_PATH} \
       -allowProvisioningUpdates YES

You can use authentication keys For more information, see Distribute apps in Xcode with cloud signing.

To learn about the keys, run in Terminal:

man xcodebuild
**-allowProvisioningUpdates**
 Allow xcodebuild to communicate with the Apple Developer website. 
For automatically signed targets, xcodebuild will create and update profiles, app IDs, and certificates. 
For manually signed targets, xcodebuild will download missing or updated provisioning profiles.
Requires a developer account to have been added in Xcode's Accounts preference pane.

** -allowProvisioningDeviceRegistration** 
Allow xcodebuild to register your destination device on the Apple Developer website if necessary. Requires -allowProvisioningUpdates.

**-authenticationKeyPath**
Specifies the path to an authentication key issued by App Store Connect. If specified, xcodebuild will authenticate with the Apple Developer website using this credential. Requires -authenticationKeyID and -authenticationKeyIssuerID.

**-authenticationKeyID**
Specifies the key identifier associated with the App Store Connect authentication key at -authenticationKeyPath.  This string can be located in the users and access details for your provider at (URL: https://appstoreconnect.apple.com)

**-authenticationKeyIssuerID**
Specifies the App Store Connect issuer identifier associated with the authentication key at -authenticationKeyPath.  This string can be located in the users and access details for your provider at (URL: https://appstoreconnect.apple.com)

Every time the CI process is completed, some error accounts will be generated in xcode-settings-account. How should I solve this problem?

i have the same problem. I've spent days working on this, very frustrating issues. @Applesupport any ideas - urgent

@AdamShi , @sepccom Does the issue still occur after using xcodebuild with the authentication keys? If your response is yes, please file a bug report and post the Feedback number here.

Accepted Answer

@AdamShi , @sepccom Additionally, you can workaround this issue by running the following command in Terminal:

defaults delete com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists

The command solved this issue for me as well. Thank you! I noticed that before executing the command, there were n+1 different accounts listed in the Xcode 16 Settings - Accounts tab. The first one was my development account, but after that, there was a long scrollable list of ‘Unknown dev accounts’ (or something like that. Unfortunately, I had already deleted them all). With the command you mentioned, I was able to clear the entire list. After that, I logged in with my development account, and so far, everything has worked correctly.

(My use case is somewhat unusual, as these Xcodes are on CI/CD machines performing repetitive tasks (and mostly tasks run through CLI tools).)

We also see this error in our CI/CD pipeline (MS DevOps). defaults delete com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists deletes all developer accounts stored in Xcode. However, the error still occurs after re-adding the correct developer account. Are there any further details?

XCodeBuild (Xcode16) account verification error
 
 
Q