Codesign script can't find certificates that are active in the keychain. How do I fix this error?

A few years ago I had developer certificates on another Mac computer running High Sierra where I successfully code signed my apps. They were in my keychain and in Xcode. All those certificates have expired. I was using maybe Xcode 9 or earlier. The latest version of Xcode that you can run on High Sierra is 10.1.

I have resumed app development using a M1 computer since you have to be running macOS 10.14 or later to upload to their App Stores. I created new certificates using my Apple Developer account in my browser and installed them in the keychain. All certificates have been updated to Always Trust.

When I run the following script:
Code Block
echo "Starting Signing..."
codesign -o runtime -f --deep -s --verify --verbose "Developer ID Application: my corp (my id)" --entitlements ~/myappfolder/my_entitlement_file.entitlements "~/myappfolder/my_app/Contents/"
echo "Signing app ..."
codesign -o runtime -f --deep -s --verify --verbose "Developer ID Application: my corp (my id)" "~/myappfolder/my_app"
echo "Verify Signing of app ..."
codesign -vvv -d "~/myappfolder/my_app"
echo "Done Signing..."

I get the following output in my Terminal:
Code Block
Starting Signing...
error: The specified item could not be found in the keychain.
Signing app ...
error: The specified item could not be found in the keychain.
Verify Signing of app ...
~/myappfolder/my_app.app: No such file or directory
Done Signing...

I executed the following Terminal command:
Code Block
security find-identity -p codesigning

...and saw this output.
Code Block
Policy: Code Signing
 Matching identities
   0 identities found
 Valid identities only
   0 valid identities found

I looked in Xcode 12.4 and my old certificate data that has expired appears when I click the Manage Certificates button in Preferences->Accounts. I can't remove them from Xcode even though I removed them from the High Sierra keychain and my Apple Developer account using my browser. When I do a right click on the expired certificate the option Delete Certificate is blocked. All I can do is Export Certificate and/or Email Creator.

The only option I have is to add a new certificate. I can't do that because I already have active certificates. I'm not sure if it's checking my Keychain to say I have active certificates or not because I don't have any active ones in Xcode. I can't create a new pair of Developer ID certificates because I have reached the limit. By design they can't be revoked according to Apple Support.

I contacted Apple Developer support about this but all I received was an email with a lot of links to go through. I have searched those links but didn't find any answers. After doing web searches I only found solutions for older versions for Mac and Xcode. I can't find any YouTube videos as the last 'customer support' representative suggested yesterday in yet another email with links.

I don't know if the problem is related to old certificate data created in Xcode 10.1 that is a different format than the current data for Xcode 12 or not.

I don't know the next step to take to resolve this problem.
Developer ID certificates are precious; see this post for some background on what I mean by that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Codesign script can't find certificates that are active in the keychain. How do I fix this error?
 
 
Q