How do I completely uninstall the OS X developer tools?

2

3

I have Apple’s developer tools installed on my Mac and there is some linking weirdness that is preventing some of the binaries from running. The problem was not solved by reinstalling Xcode and its command-line tools, either the public version 4 or the developer-preview version 5. How can I completely delete the command-line tools in preparation for reinstalling them cleanly?

bdesham

Posted 2013-08-29T14:57:37.573

Reputation: 167

How are you uninstalling Xcode exactly? – Ramhound – 2013-08-29T15:08:49.323

@Ramhound That’s my question. It’s possible to “uninstall” Xcode by dragging Xcode.app to the trash, but that doesn’t touch any of the command-line tools. – bdesham – 2013-08-29T15:35:15.060

Answers

4

As stated by Cocoanetics here, you can use this script to remove the tools completely:

remove_CLI_tools.sh

RECEIPT_FILE=/var/db/receipts/com.apple.pkg.DeveloperToolsCLI.bom
RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.DeveloperToolsCLI.plist

if [ ! -f "$RECEIPT_FILE" ]
then
  echo "Command Line Tools not installed."
  exit 1
fi

echo "Command Line Tools installed, removing ..."

# Need to be at root
cd /

# Remove files and dirs mentioned in the "Bill of Materials" (BOM)
lsbom -fls $RECEIPT_FILE | sudo xargs -I{} rm -r "{}"

# remove the receipt
sudo rm $RECEIPT_FILE

# remove the plist
sudo rm $RECEIPT_PLIST

echo "Done! Please restart XCode to have Command Line Tools appear as uninstalled."

Pay attention to the disclaimer right under the script on that page:

Use at your own risk, it might remove more than you bargained for. So make sure you made a time machine backup before running this.

MoonSire

Posted 2013-08-29T14:57:37.573

Reputation: 874

Though the .bom and .plist files are named differently on OS X 10.10, this approach worked fine on Yosemite, too, to uninstall the command line tools installed by invoking "git". – Thomas S. – 2014-12-03T08:59:35.243