Command codesign failed with a nonzero exit code or revoke certificate for IOS / Xcode problems

if you have experienced a similar error, try my method and see if you can solve it. The error case diagram is as follows:

  1. according to my experience, the cause of this problem is that I mistakenly reset the keychain access to the default, so I lost my development certificate.
  2. how do I solve this problem?
  3. I clean up my apple development certificate from Keychain Access
  4. I clean up my apple development private key
  5. and I get a new 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. Xcode can create a new one after revoking your existing certificate.
  6. relocates to Xcode-> Preferences-> The Accounts tags – & gt; Find team name -&gt under Apple ID; Double-click on it – & gt; Click the + button in the bottom left corner of the box -> Select App Development
  7. in the project -> Signing & Capabilities-> From the Team drop-down menu, select “None”
  8. to re-select the correct development Team
  9. to rebuild the CMD + b project
  10. by shift + CMD + k clean project

Read More: