Private key not installed in your keychain with xcodebuild

Hello everyone,

Since I changed my certificate,I cant build anymore with xcodebuild.

I can build and export using xcode archive and organizer without issues. My private key is installed correctly.

But, when I use xcodebuild manually from the terminal, it first throw errors I don't fully understand and then says that I dont have a private key for my certificate.

Here is the xcodebuild command I use

terminal% /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -verbose -scheme MyApp -workspace MyApp.xcworkspace -configuration Release clean archive -archivePath _build/MyApp.xcarchive -allowProvisioningUpdates

Here is the error

2020-12-03 07:57:01.238 xcodebuild[4658:241714] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-17535/IDEFoundation/Provisioning/Logging/IDEProvisioningLedger.m:172 Details: Unable to close provisioning ledger entry because not all of its subentries are closed Object: <IDEProvisioningLedgerEntry: 0x7ff4f0a54e00> Method: -closeWithError: Thread: <NSThread: 0x7ff4ef32abc0>{number = 11, name = (null)} Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.

followed by

error: Revoke certificate: Your account already has an Apple Development signing certificate for this machine, but its private key is not installed in your keychain.


I read a lot of posts from people that have a similar issues
  • I check, double checked, revoked so many times my certificats

  • I reinstalled command line tools to try and solve the issue.

  • I tried specify the keychain in case it could'nt find it alone

  • I tried to lock unlock the keychain in case

  • I tried it in my own computer and it works fine


I don't know what to do right now to fix the problem apart from re-installing macos completely :(.

PS:
The build machine originally use jenkins 2.244. The error is the same with jenkins.
The version of xCode is Version 12.2 (12B45b)
The os is Catalina 10.15.5 (19F101)


Thank you
Private key not installed in your keychain with xcodebuild
 
 
Q