-
Notifications
You must be signed in to change notification settings - Fork 68
Remove Old Versions of XCode
Removing Already Installed XCode Tools
There is no simple way to get rid of the installed files as they are copied all over the place. But there is a manifest file which lists all folders and files that are installed by the package. This allows us to go all “brute force” on the tools and remove them.
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."
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.
There is a second copy of the CLI Tools still present on your system even if you remove them with the above script. Xcode downloads end up in ~/Library/Caches/com.apple.dt.Xcode/Downloads and there are another 112168 KBytes to be reclaimed by removing the DMG file that you find in there, at the time of this writing named Xcode.CLTools.10.8-1.7.dmg.