errSecInternalComponent Command CodeSign failed with a nonzero exit code

My app was working properly running on my iPhone.
However, it stoped and I'm getting the following main error:
Code Block language
/Users/username/Library/Developer/Xcode/DerivedData/myapp-apyglxnnthiwyufnfwrcifovdhhw/Build/Products/Debug-watchos/myapp WatchKit Extension.appex: errSecInternalComponent
Command CodeSign failed with a nonzero exit code


Code Block language
CodeSign /Users/username/Library/Developer/Xcode/DerivedData/myapp-apyglxnnthiwyufnfwrcifovdhhw/Build/Products/Debug-watchos/myapp\ WatchKit\ Extension.appex (in target 'myapp WatchKit Extension' from project 'myapp')
  cd /Users/username/Desktop/myapp
  export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
   
Signing Identity:   "Apple Development: myemail@gmail.com (CODE)"
Provisioning Profile: "iOS Team Provisioning Profile: com.username.myapp.watchkitapp.watchkitextension"
           (ANOTHERCODEHERE)
  /usr/bin/codesign --force --sign CODEHERE --entitlements /Users/username/Library/Developer/Xcode/DerivedData/myapp-apyglxnnthiwyufnfwrcifovdhhw/Build/Intermediates.noindex/myapp.build/Debug-watchos/myapp\ WatchKit\ Extension.build/myapp\ WatchKit\ Extension.appex.xcent --timestamp\=none /Users/username/Library/Developer/Xcode/DerivedData/matchpoint-apyglxnnthiwyufnfwrcifovdhhw/Build/Products/Debug-watchos/myapp\ WatchKit\ Extension.appex


I have tried turning on and off the laptop, tried to lock and unlocked the login keychain, I also removed the login keychain, I unregistered the device and added it again to Xcode, I removed Xcode and installed it again, I removed my account from Xcode and add it again...

What else can I do?
After several days, I could finally check what was not working. Seems that I had two keychains so just removing one fixed the issue. Also, I changed all the config to use Local sign in instead of Development.

Dropping this here in the hope that it improves the chances of folks finding it: Resolving errSecInternalComponent errors during code signing

errSecInternalComponent Command CodeSign failed with a nonzero exit code
 
 
Q