3

Someone recently posted a similar issue at can't exec 'codesign' (No such file or directory)

However, for whatever reason, it has received a down-vote rather than something helpful. So I am going to try to post this myself, with some additional data in hopes that some kind SO'er has been through this or just knows what the problem is.

I have a project that builds fine under Xcode 4.x, but ever since installing Xcode 5 DP2 (and DP3,4 and 5) and now the released version, I get this error when trying to build or archive to anything but the simulator:

CodeSign /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
    cd /Users/cb/Development/MyAppCore/FrontEnd/Mobile/iOS/MyApp
    setenv CODESIGN_ALLOCATE /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH:/usr/local/mysql/bin:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin"
    Using code signing identity "iPhone Developer: CB (D4HZSHL6DF)" and provisioning profile "MyApp_DEV" (BB1C0589-147E-4E12-945D-8FB093B70C70)
    codesign --force --sign F5...B73 --resource-rules=/Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/ResourceRules.plist --entitlements /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.xcent /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app

If I open Terminal and cd to

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/

and then run the command from there, it executes just fine. So the tools seem alright, as do the provisioning profiles. The problem seems to be with Xcode itself.

It should be noted that I have deleted Xcode completely, as well as my codebase, along with all provisioning profiles and certs. I re-checked-out my code, and re-installed Xcode 5 from a fresh download, entered Apple ID into Xcode and re-created/fetched the certs and profiles, and still have the same issue.

I also went in to the project file itself and removed duplicate PROVISIONING_PROFILE entries per a couple of answers I found, to no avail.

I can build this same project from 2 other machines using Xcode 5, so it is something happening specifically on my box, or with my particular installation, it would seem. But other than that, I am stumped.

Has anyone seen/fixed this, or have any ideas of where to look for an answer?

Thanks for any input!

Community
  • 1
  • 1
Raconteur
  • 1,381
  • 1
  • 15
  • 29
  • Have you made any major edits to your $PATH lately? Any other major changes to your system? I am having the same issue on one mac, and I think I messed up my path. – Chris Truman Sep 16 '13 at 22:35
  • 1
    Did you install the XCode command line tools from within XCode 5? – RyanR Sep 16 '13 at 22:41
  • @RyanR I did when I installed the GM – Chris Truman Sep 16 '13 at 22:44
  • 1
    Perhaps: sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer – Matt Wilding Sep 16 '13 at 22:48
  • @MattWilding hmm didn't help, should codesign exist at this path? /Applications/Xcode.app/Contents/Developer/usr/bin/codesign? – Chris Truman Sep 16 '13 at 22:53
  • 1
    Nope, it was a shot in the dark. That's historically how I've managed switching command line tools between beta and release versions of Xcode. Forgetting can cause some odd errors. – Matt Wilding Sep 16 '13 at 23:14
  • @MattWilding thanks for the idea. Codesign runs fine from the command line, but just not in xcode 5. – Chris Truman Sep 16 '13 at 23:17
  • I'm having the same problem and don't know what to do. @ChrisTruman could you please give a hint how command line worked for you? – Abdullah Umer Sep 26 '13 at 21:17
  • @AbdullahUmer as I mentioned over on the other question, you need to have your path set to include codesign. The path variable that xcode gets is different than your terminal. – Chris Truman Sep 26 '13 at 21:28
  • I changed xcode path using sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer. But this didn't work. – Abdullah Umer Sep 26 '13 at 21:31

4 Answers4

4

I copied codesign from /usr/bin/ to:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/u‌​sr/bin

and it worked for me.

Abdullah Umer
  • 4,234
  • 5
  • 36
  • 65
3

Try this:

For Mountain Lion before starting signing process Please run below command as first command.

For Xcode 4.x: export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"

For XCode 5: export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"

Meet
  • 4,904
  • 3
  • 24
  • 39
1

Solved my problem, thanks for the help. The issue was with my path. I had set my path via /etc/launchd.conf and I was driving myself insane trying to edit my path via ~/.bashrc etc. Make sure /usr/bin is in the path that xcode picks up. This page reminded me: http://overwatering.org/blog/2012/08/setting-path-osx-mountain-lion/

Chris Truman
  • 913
  • 1
  • 7
  • 25
0

If you added the flag --deep to "Other code signing Flags" i.e. using cut copy paste, it may happen that an "invisible" char was added. In this case the error message is like:

/usr/bin/codesign --force --sign "" --deep --entitlements (...) No such file or directory

If you see those two quotes "" then there is an invisible char before '--deep' in your compiler settings.

In this case the compiler throws the error message "No such file or directory". (/usr/bin/codesign seems to not be existing, but it is (!))

To resolve this issue go to build settings, search for 'Other code Signing Flags', delete all entries, and retype them manually (no cut copy paste).

JackPearse
  • 2,922
  • 23
  • 31