Search code examples
iosxcodecode-signingxcodebuild

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


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.


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