Xcode 16 on macOS Sequoia Keeps Removing Apple Accounts

I've recently set up new M4 Mac Minis with macOS Sequoia and Xcode 16. After logging into my Apple account in Xcode, everything works fine initially. However, the next day—or sometimes just a few hours later—my builds fail, and when I check the Accounts tab in Xcode's Settings, my account is missing. I have to re-add and re-authenticate my account, only for the same issue to recur later.

To investigate further, I upgraded an older Mac Mini from macOS Sonoma and Xcode 15.1.0 to macOS Sequoia and Xcode 16.2. Unfortunately, this machine now exhibits the same behavior, suggesting the issue is related to either macOS Sequoia or Xcode 16.

Has there been a change in Xcode or macOS that causes this automatic removal of accounts? Is there a solution or workaround to prevent Xcode from removing my Apple account?

Any insights or suggestions would be greatly appreciated!

We observe exactly the same behavior on a M1 Mac mini with Xcode versions 16 - 16.2 on Sequoia as well as on a M4 Mac mini with Xcode 16.2. We wiped and reinstalled the M1 Mac mini and the problem persists.

Builds are done with xcodebuild executed in a gitlab shell runner.

Same issue here. I migrated from an Intel mac mini for my CI to an M4 mac mini. Keeps loosing the account, seems a bit random but I think it's linked to TestFlight deployments. The issue is present on the mac mini itself as well as on a VM run on that mac mini (freshly set up as well). Sequoia 15.3.2 and Xcode 16.1/16.2

And I thought I'm going crazy. Same story here, M4 Mac mini with Xcode 16.2, MacOS 15.3.2 (24D81). Using github pipelines and fastlane for iOS builds and distribution to TestFligh.

I'm also seeing exactly the same issue with Sequoia 15.4.1 and Xcode 16.2 two. I have multiple Mac Minis (M2 and currently setting up some M1s) setup as Gitlab CI runners, and the Apple IDs for code signing randomly get removed after a random period of time.

I tried running: defaults write com.apple.dt.Xcode DVTDeveloperAccountUseKeychainService -bool NO to store it outside the keychain, but this doesn't appear to make a difference.

What is interesting is when re-adding the account, I no longer get prompted for 2FA, requiring only a password, which suggests the trusted status for the account is being cached somewhere correctly...

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:

  1. loginwindow locks the screen.
  2. xcodebuild starts. com.apple.dt.Xcode.KeychainService calls SecItemCopyMatching.
  3. secd returns -25308 (errSecInteractionNotAllowed), "Access to item attempted while keychain is locked".
  4. xcodebuild logs: DVTDeveloperAccountManager: Failed to load credentials for <identifier>: "Invalid credentials in keychain for <identifier>, missing Xcode-Username".
  5. 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.