I found one cause of this account loss on my Mac. It is possibly the same cause on your CI machines.
Environment: Xcode 27.2 (27B52), macOS 26.7.2. The same loss occurred at intervals of approximately one week since Xcode 16.
Cause: xcodebuild started while the Mac screen was locked. At that time the data protection keychain is locked. The unified log shows this sequence:
- loginwindow locks the screen.
- xcodebuild starts. com.apple.dt.Xcode.KeychainService calls SecItemCopyMatching.
- secd returns -25308 (errSecInteractionNotAllowed), "Access to item attempted while keychain is locked".
- xcodebuild logs: DVTDeveloperAccountManager: Failed to load credentials for <identifier>: "Invalid credentials in keychain for <identifier>, missing Xcode-Username".
- xcodebuild writes the com.apple.dt.Xcode preferences. The account is removed from DVTDeveloperAccountManagerAppleIDLists.
The same build did not fail when the screen was unlocked. My build was an iOS device build with automatic signing. Another developer found the same sequence and reports that only builds with -allowProvisioningUpdates read the account: https://idvork.in/apple-bugs
To check if you have the same cause, run this after the account is lost:
log show --last 1h --predicate 'process == "secd" AND eventMessage CONTAINS "-25308" AND eventMessage CONTAINS "com.apple.dt.Xco"'
The credentials are not deleted from the keychain. Only the identifier is removed from the preferences. If you write the identifier back, Xcode shows the account and its teams again. A new sign-in is not necessary:
defaults write com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists '{"IDE.Identifiers.Prod" = ({identifier = "<identifier>";});}'
Do this while Xcode is not running and the screen is unlocked. To know the identifier, record the output of this command while the account is still signed in:
defaults read com.apple.dt.Xcode DVTDeveloperAccountManagerAppleIDLists
I filed FB25701993.