certificatecode-signingcodesignp12

How to use codesign command


I am trying to use codesign command to sign bundle.

First of all I have got p12 file and I have imported into my keychain.

However when I try to use codesign like this:

codesign -v --force --verify --deep --verbose --sign <ID> <MyApp.app>

It says 'no identity found'. The identity field I got it from enter image description here

What am I doing wrong please?

Thanks in advance


Solution

  • Before you run codesign command, you need to unlock your keyChain, either by clicking on unlock on the keychain app or run security unlock-keychain, otherwise you can get inconsistent result because sometimes the keychain is already unlocked, sometimes not.

    You might also need to include the --keychain option in your codesign command, depending on your configuration.

    You can verify if the identity is available in your current shell environment by security find-identity -p codesigning