Apple ID dissapears from Xcode and build is failing

I'm calling this command to export archive:

xcodebuild -exportArchive -archivePath .build/XYZ.xcarchive -exportPath .build/XYZ.ipa -exportOptionsPlist Authenticator/ExportOptions.plist -quiet -allowProvisioningUpdates

Here is my exportOptions file content

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>method</key>
	<string>app-store-connect</string>
	<key>signingStyle</key>
	<string>automatic</string>
	<key>teamID</key>
	<string>ABCD</string>
</dict>
</plist>

Most of the time this command fail with this error:

error: exportArchive No Accounts
error: exportArchive No signing certificate "iOS Distribution" found

What we found is that our Apple ID just disappear from Xcode and we need to add it again manually.

So there are two questions here:

  1. Why Apple ID account dissapears and how I can fix this?
  2. Is there an option to not use Apple ID account in Xcode and for example to use -authenticationKeyID flags of xcodebuild?

Just to mention this happens only on our CI machine and not locally.

Apple ID dissapears from Xcode and build is failing
 
 
Q