Question

I just updated to the newest version of Xcode and encountered an error while running our automated build scripts (they use the xcodebuild and xcrun commands).

The error occurs immediately after the ### Codesigning '/Users/... log statement and looks like this:

Program /usr/bin/codesign returned 1 : [/var/folders/__/63j90nkn2lg18ct1nq791_nc0000gn/T/g5hbigh1tM/Payload/CurrentTarget.app: replacing existing signature
/var/folders/__/63j90nkn2lg18ct1nq791_nc0000gn/T/g5hbigh1tM/Payload/CurrentTarget.app: cannot find code object on disk

I found docs here listing and briefly describing the error but no specifics about how to resolve it.

Because I spent far too long looking for the resolution to this (nothing on S.O.) I'm going to post the answer below in case others encounter the same problem.

Was it helpful?

Solution

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...

OTHER TIPS

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 -.

Code Signing 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  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top