iOS: Error executing codesign: iPhone Distribution: no identity found

Problem

The following error may occur when signing an iOS app:

Error executing codesign:
iPhone Distribution: no identity found

Cause

This error relates to the re-signing of an app after it has been secured. The process of securing changes the nature of the app, requiring it to be re-signed in order to be distributed to an iOS device. This error occurs if there is a mismatch between the certificate and the provisioning profile—usually the provisioning profile does not specify an identify that matches the certificate used to sign the app. 

Solution

The error is not specific to signing secured apps, but is commonly encountered when signing apps outside of Xcode. Make sure that these pieces are in place:

  • You have a valid provisioning profile. 
  • Both the signing certificate associated with your provisioning profile and the private key used to create your signing certificate are in your keychain and associated with your signing certificate.