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

Thu, Aug 2

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.

6 comments

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

by Arthur on Sep 6, 2012. #

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

by Jeremy on Dec 11, 2012. #

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”

by Adrian on Dec 21, 2012. #

Glad to know if helped!

by John Muchow on Dec 21, 2012. #

Thanks tons, the below line resolved my issue

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

by Setra on Apr 9, 2013. #

It helped me. Thank you very much John!

by gala on Feb 5, 2013. #