Code Signing Error : object file format unrecognized, invalid, or unsuitable

I recently upgraded to Mac OS X Mountain Lion, which for the most part has been a good experience. However, code signing of applications from a terminal window began to generate an error:

C

I found that setting the CODESIGN_ALLOCATE environment variable as follows, before calling the codesign application, will take care of the issue:

export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"

I added the above in the bash shell script that I use for application signing. Adding this setting in the .bash_profile file would also be an option so the change would be system wide.

  1. Thanks for the tip. I encountered the same problem your solution worked for me.

  2. Well, that at least changed the error message for me.

    Used to be:

    prompt$ codesign -s “Certificate” -f My.app
    My.app: object file format unrecognized, invalid, or unsuitable

    Now it’s:

    prompt$ export CODESIGN_ALLOCATE=”/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate”

    prompt$ codesign -s “Certificate” -f My.app
    My.app: cannot find code object on disk

  3. Thank you for your post, I spent hours researching this issue. Your recommendation resolved my issue. The majority of solutions mention that the following should resolve, but in my case it did not.
    “sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin”

    • Thanks tons, the below line resolved my issue

      “sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin”

Comments are closed.