I had serious problems from two versions of Xcode on the same machine. I removed all Xcode app instances & many other non-System 'xcode'-related files, then reinstalled the app (4.6.2), fixing my original problem. But xcodebuild
and xcode-select
are still not available, which I need to run PhoneGap for iOS. Within Xcode, the Preferences => Downloads => Command-line Tools item is marked "Installed", with no option to delete or re-install. I tried removing xcrun
, but that didn't work. How do I fix this?
- I run
sudo rm -rf /Library/Developer/CommandLineTools
- and then
xcode-select --install
Problem fixed on my side
-
11
-
-
1May go with
sudo rm -rf `xcode-select -p` && xcode-select --install
just to be safe. – AlexV Apr 11 '20 at 3:29 -
1You might also need to reset
xcode-select
's path afterwards (at least I had to), by usingsudo xcode-select -r
– Jens C. Thuren Lindahl Apr 28 '20 at 9:57 -
FYI: I navigated to
/Library/Developer/
package and did not see theCommandLineTools
package. Running the command still worked though. – Prince Aug 25 '20 at 22:00
The command line tools are installed like other OS X packages, so you may need to delete the receipt file from the receipts database (which used to be trivial since you could delete the file from /Library/Receipts but now is more complicated and needs a short article on the receipts database).
Rather than mess with that, why not just download the stand alone installer and wait for a new version of Xcode to clean up your receipts database for you?
This URL is fairly open (even the search engines can index it) but you might need to make a free Safari or free Mac developer account to log in and get this package.
If this happened to me, I'd simply change my Time Machine to exclude system files and then install a new OS onto a spare volume. I'd make a junk admin user that I'll delete and use that user to install Xcode and the command line tools and then finally restore from Time Machine. As long as everything worked, I'd clone that to my main drive or repeat the wipe/reinstall process - whichever is easier for you to perform.
-
Forgot to mention that I tried that; xcodebuild still unavailable in standard executible dirs. There is one in Xcode.app/Contents/Developer/usr/bin/xcodebuild. – sierra Jun 10 '13 at 17:05
-
xcrun
will tweak your path if you have multiple toolsets installed. You could justmv
those binaries into /usr/bin if you wanted a quick fix. Again with WWDC running as I type this, a new version of Xcode should drop within a day or two... – bmike♦ Jun 10 '13 at 17:10 -
-
Here's a paste of /usr/bin from a clean Mac with the latest command line tools. You can diff it with your listing (ls -la /usr/bin) cl.ly/PYyh to see what needs to be copied and what Apple left in the Xcode.app /Developer folder. – bmike♦ Jun 10 '13 at 17:51
-
No dice: $ xcodebuild dyld: Library not loaded: @rpath/DVTFoundation.framework/Versions/A/DVTFoundation Referenced from: /usr/bin/xcodebuild Reason: image not found Trace/BPT trap: 5 – sierra Jun 11 '13 at 13:46
-
Not available. I mistakenly removed it, and I didn't get it back when reinstalling command line tools. – sierra Jun 11 '13 at 13:40
This seems to work for XCode 5, remove --dry-run
to actually perform copy.
sudo rsync -ai --exclude subversion\* --exclude SVN\* /Applications/Xcode.app/Contents/Developer/usr /
sudo ln -sf /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild /usr/bin/
Or go to https://developer.apple.com/downloads/ and search for "xcode" - there are downloadable packages for 10.5 through to 10.10
Referring to the help text, running xcode-select -r
will reset xcode, which may help with install-time issues.
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path