Updating Xcode yields error “cannot find code object on disk” during codesigning

坚强是说给别人听的谎言 提交于 2019-11-30 09:14:00

It's worth noting that you may need to update the environment variable that specifies the location of codesign_allocate:

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

But the real solution for me came from here:

ln -s /usr/bin/codesign_allocate /Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate

Hope this saves someone some time...

William Denniss

I had this error when running a build script on XCode 4.5 (installed at /Applciations/XCode4_5), with XCode 5 installed more recently (in the main dev directory at /Applications/XCode) so that I can still target the iOS 6 SDK on an older project when needed.

I had previously applied the workaround mentioned in https://stackoverflow.com/a/18768869/72176 to my build script, by exporting the CODESIGN_ALLOCATE environment variable.

In this recent instance of this problem, I actually fixed it by removing the old workaround. So my advice: if you get this error recently, and you've previously applied the workaround: try unapplying it and see if that helps!

The cannot find code object on disk error occurred on two of my projects after an update to Xcode 9.3.

Case 1: The issue was found to be CODE_SIGN_IDENTITY -.

The fix was to change - to something specific.

In the Xcode Project Inspector, "Code Signing Identity" becomes either Don't Code Sign or some code sign identity.

Thus CODE_SIGN_IDENTITY "-" becomes either "" (to not code sign) or a specific code sign identity.

Case 2: When using the Swift 4.1 development snapshot toolchain, the solution was to add a .xcconfig Configurations Settings File to the Xcode project. The default CODESIGN_ALLOCATE was set to the swift-4.1-DEVELOPMENT-SNAPSHOT-….xctoolchain/usr/bin path which does not contain the codesign_allocate executable. The .xcconfig can expressly set CODESIGN_ALLOCATE for the build.

example.xcconfig

// file: example.config
CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!