Signing app in XCode: specified item could not be found in the keychain

When archiving an app in XCode (Product > Archive) I get the following error:

CodeSign /Users/***/Library/Developer/Xcode/DerivedData/name-***/Build/Intermediates/ArchiveIntermediates/name/InstallationBuildProductsLocation/Applications/name.app cd /Users/***/Documents/name/App/platforms/ios export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" Signing Identity: "iPhone Developer: *** *** (S5L8942T98)" Provisioning Profile: "iOS Team Provisioning Profile: ***" (***) /usr/bin/codesign --force --sign *** --entitlements /Users/***/Library/Developer/Xcode/DerivedData/name-***/Build/Intermediates/ArchiveIntermediates/name/IntermediateBuildFilesPath/name.build/Release-iphoneos/name.build/name.app.xcent --timestamp=none /Users/***/Library/Developer/Xcode/DerivedData/name-***/Build/Intermediates/ArchiveIntermediates/name/InstallationBuildProductsLocation/Applications/name.app error: The specified item could not be found in the keychain.

I revoked all my certificates and created new provisioning profiles, unfortunately it didn't help.


Obviously something is missing in my keychain, but what? This is a screenshot of my keychain: https://i.stack.imgur.com/wjUXn.jpg

The Id matches the one from the error code. Can anyone give me a hint please?

Replies

I have same issue. Very annoying. I have urgent tasks to complete, now unable to finish them.

Any fix? I've got same issues, spent a day but nothing.

I have figured it out... Since many years, I have attached a smartcard to my computer which contains a certified private key to sign emails and PDFs. This never was a problem when building apps with Xcode. Since I have installed 10.14, I get the "The specified item could not be found in the keychain." error when I have attached the smartcard. The solution in my case is to simply remove it.


More generally: When the smartcard is inserted, I see an additional keychain in the Keychain Access app. It's the first one in the list and it is locked. My guess is that Xcode / codesign only tries to find the code signing certificate / private key in this additional keychain instead of in the login keychain. So the general solution may be to have a look at Keychain Access and check if there is anything unusual.