codesign_allocate helper tool cannot be found or used
Did some digging on this one and found a few good Stack responses to similar problems - but no generic solutions for all comers, so I figured I’d make one. :)
The cause of the problem is: in modern versions of OSX, if you install Xcode from the App Store, it installs itself like all other Apps - which means it’s in a different directory than was historically the case. Unfortunately, this has far-reaching implications that affect both Xcode and its command-line tools and - in fact - other things that reach far beyond the scope of this question.
So, until they fix it, let’s talk workarounds. Many people recommend changing your Xcode system variables to point to the ‘App Store’ folder, but I think this is a dangerous overkill - you just don’t know what kind of mayhem it may cause if they ever fix their pathing!
Instead, I recommend using Terminal to change only the system link affecting ibtool (or whatever tool you’re using), like so:
Step 1: Remove the old system link
sudo rm /usr/bin/ibtool
Step 2: Create a new system link
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool /usr/bin/ibtool
For reference only, here is another command that will fix this - but I DO NOT recommend using it for the reasons stated above:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
I can see the argument that xcode-select might be a proper solution if you have all kinds of /Developer-related errors, but in that case I would just reinstall Xcode without using the App Store and get it going good from the start.
For the rest of us already too far down the App Store path to re-do it all, see above.
object file format unrecognized, invalid, or unsuitable
/usr/bin/codesign failed with exit code 1
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old （我不需要。因为两个Xcode冲突，谁都没有给我一个codesign_allocate到该目录）
sudo ln -s /DeveloperXcode4/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin