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

3

12

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.

Limbate answered 12/9, 2013 at 15:46 Comment(0)
L
15

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

Limbate answered 12/9, 2013 at 15:48 Comment(1)
Glad it helped! I looked around for far too long and was worried I'd have to rewrite a whole bunch of AutoBuild code.Limbate
G
6

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://mcmap.net/q/920010/-updating-xcode-yields-error-quot-cannot-find-code-object-on-disk-quot-during-codesigning 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!

Generalship answered 10/12, 2013 at 12:51 Comment(2)
Thank you! Removing a pre-existing export of CODESIGN_ALLOCATE in my build script resolved the issue for me.Gosney
yep export no longer needed, open a new terminal tab to clearMcculloch
G
1

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  
Gaussmeter answered 17/2, 2018 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.