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

August 2, 2012

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:

object file format unrecognized, invalid, or unsuitable

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.