Codesign returned 1 (object ifile format invalid or unsuitable) bug

╄→гoц情女王★ 提交于 2019-11-29 20:36:46
Jon Egeland

Just so that this can be taken off the unanswered list. Like you said, you need to add CODESIGN_ALLOCATE to the $ENV array:

$ENV{CODESIGN_ALLOCATE} = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate';

If everyone is in agreement here, I think this question can finally be closed.

When using a more recent version of Xcode, the default location is:

$ENV{CODESIGN_ALLOCATE} = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate';

In case you get this on a recent version of Xcode, what you actually want is, in the shell:

export CODESIGN_ALLOCATE=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate

which will use the codesign_allocate from the version of Xcode you are using.

You can update the version of Xcode the command line tools use by running xcode-select -switch

I had this workaround in place for a long time, but after upgrading to Xcode 4.3 with iOS 5.1 SDK, my signing script (which calls codesign) stopped working with a cannot find code object on disk error:

output/Enterprise/Payload/MyProduct.app/MyProduct: replacing invalid existing signature    
output/Enterprise/Payload/MyProduct.app/MyProduct: cannot find code object on disk     
Code signing failed, not creating .ipa file    

It seems this workaround isn't necessary for binaries built with Xcode 4.3. To fix, I updated my bash script to check if the location exists before exporting it:

  # Only export the environment variable if the location exists,
  # otherwise it breaks the signing process!
  if [ -f "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate" ]
  then
    echo Export environment variable for codesign_allocate location
    export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
  fi
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!