9

I upgraded my Mac to 10.10.3 and Xcode to 6.3.1 yesterday; today I can't use git, codesign_allocate....and more.

`sh: line 1: 18421 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -find codesign_allocate 2> /dev/null
codesign_allocate: error: unable to find utility "codesign_allocate", not a developer tool or in PATH
/Users/ylx/Library/Developer/Xcode/DerivedData/test-ahpvhmtqeafuveekexklyxulvmfa/Build/Products/Debug-iphoneos/test.app/Frameworks/libswiftCore.dylib: the codesign_allocate helper tool cannot be found or used
*** error: Couldn't codesign /Users/ylx/Library/Developer/Xcode/DerivedData/test-ahpvhmtqeafuveekexklyxulvmfa/Build/Products/Debug-iphoneos/test.app/Frameworks/libswiftCore.dylib: codesign failed with exit code 1
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-stdlib-tool failed with exit code 1`
Unheilig
  • 16,196
  • 193
  • 68
  • 98
six
  • 115
  • 1
  • 1
  • 7
  • Did you install the command line tools? What does `xcode-select -p` produce? – trojanfoe Apr 24 '15 at 13:38
  • ylxdeMacBook-Pro:bin nahaowan$ xcode-select -p /Applications/Xcode.app/Contents/Developer – six Apr 24 '15 at 13:52
  • same issue since Xcode 6.3.1. Also tried Xcode 6.4 Beta 2: same issue. Do you found a solution? – Stone May 02 '15 at 20:29
  • @trojanfoe: i have reinstalled the command line tools --> Same Issue – Stone May 02 '15 at 20:37
  • I've tryed reinstall the command line ,not work!At last I reinstall the mac!It's a work Computer,I can't wait too long! – six May 04 '15 at 01:55

7 Answers7

11

Try running the following command:

locate codesign_allocate

Note, you may need to run this command and wait a couple minutes if your locate DB isn't updated:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Then see all the spots where codesign_allocate exists. On my system, it shows up in the following locations:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
/Library/Developer/CommandLineTools/usr/bin/codesign_allocate
/usr/bin/codesign_allocate

Then ensure at least one of these is on your $PATH.

echo $PATH | tr : '\n'

On my system, /usr/bin is on my $PATH, so Xcode finds it just fine. If codesign_allocate isn't available on your $PATH, you've got two options:

  1. Add it to your path. I.e. edit your ~/.bashrc and add this line to the end (Note, you can use any path that codesign_allocate exists on. The path I'm using is just to illustrate):

    export PATH=$PATH:/Library/Developer/CommandLineTools/usr/bin/

  2. Create a symbolic link to your command line tools somewhere on a directory in your path:

    sudo ln -s /Library/Developer/CommandLineTools/usr/bin/* /usr/bin/

Hope this helps! Note, on installation of a new Xcode version, you may want to revisit this and ensure you're using the correct paths. Assuming you install over previous versions of Xcode, you should be okay, but it's something to keep in mind.

Sandy Chapman
  • 11,133
  • 3
  • 58
  • 67
  • 1
    Great answer -- turned out that upgrading to Xcode 7 Beta had renamed my `/usr/bin/codesign_allocate` to `/usr/bin/codesign_allocate_old` and Xcode 6 couldn't find it. – Dennis L Aug 07 '15 at 20:14
  • I am not sure that it is a good advice to build the `locate` DB for a Mac. Most of the files are anyway indexed for the 'spotlight search'. For other files, like the one required here, a simple command like this would be doing the job: `find /Applications/ -name codesign_allocate` – ishahak Nov 15 '15 at 15:16
  • @ishahak, find could take a very long time if you've got a lot of applications installed on your system. – Sandy Chapman Nov 15 '15 at 17:30
  • 1
    @sandy, but there is a cost of wasting space for a DB, plus performance cost for running another permanent service in your system. Besides, you can user Mac's metadata search: `mdfind -name codesign_allocate`. Give it a try! – ishahak Nov 16 '15 at 02:31
  • @ishahak : Thanks for the tip. `mdfind` seems nice. I just come from a Linux background so it takes time to migrate over to other platform dependent tools. – Sandy Chapman Dec 09 '15 at 01:08
4

Have you tried if xcodebuild command work as expected and if you have any Xcode plugins in the plugins Folder located at ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins who can cause this issue.

Atika
  • 1,560
  • 18
  • 18
  • i tried it because i have the same issue: it say's `The following build commands failed: CodeSign build/Release-iphoneos/*AppName*.app (1 failure)` – Stone May 02 '15 at 20:33
1

I struggled with this almost all afternoon and started to think it would be the end for me.

Hopefully I found a solution that might help other people. I started to wonder after I saw this error again and again :

sh: line 1: 18421 Abort trap: 6 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -find codesign_allocate 2> /dev/null codesign_allocate: error: unable to find utility "codesign_allocate", not a developer tool or in PATH

I took @sandy's answer and checked the different paths where I could find codesign_allocate. I got a pretty good hint after running both of these command:

$ /usr/bin/codesign_allocate sh: line 1: 26890 Abort trap: 6 ...

$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate Usage: .../codesign_allocate -i input [-a <arch> <size>] [-A <cputype> <cpusubtype> <size>]... -o output

Thus I simply replaced my local /usr/bin/codesign_allocate with the one from xcode and that fixed all my problems.

sudo cp -r /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin/

I hope this can help other people; good luck everybody.

Lifely
  • 1,035
  • 12
  • 22
1

Upgrading to Xcode 6.4 fixed it for me.

C. Bess
  • 567
  • 7
  • 10
1

For my case it's because the free storage of my Mac is almost zero. Clean up my disk solves the problem.

Kuang Lin
  • 43
  • 5
0

Sometimes issue is with path of Xcode's command line tool which could be fixed by fixing path of XCode. Please check path of XCode with command xcode-select -p. If it shows incorrect XCode path then you can use command sudo xcode-select -s PATH_TO_XCODE_DEVELOPER_FOLDER.

For example, sudo xcode-select -s "/Application/XCode.app/Contents/Developer"

Khushneet
  • 854
  • 9
  • 10
0

Clean up + reopen xcode worked for me