我在星期五升级到了Xcode 5 Command Line Tools。有些东西出了问题,我想回到上一个版本的Xcode 4.x。我该如何卸载Xcode 5 Command Line Tools?在发行说明中没有看到任何信息。
我在星期五升级到了Xcode 5 Command Line Tools。有些东西出了问题,我想回到上一个版本的Xcode 4.x。我该如何卸载Xcode 5 Command Line Tools?在发行说明中没有看到任何信息。
根据您是否在Mavericks中运行Xcode 5,您需要执行两个不同的操作来卸载命令行工具。
In Mavericks, Xcode includes its own copy of the Command line tools (i.e. they are bundled as part of Xcode.app). Therefore, uninstalling the Xcode (check instructions below) will remove the Command line tools too.
For older Mac OSX versions running Xcode 5 or older versions (Xcode 4.x), you can find previous SO answers which explain how to uninstall Xcode's command line tool. You can use this script (Read more about it in this post):
# remove_CLI_tools.sh
# written by cocoanetics:http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
# modified by yoneken
#!/bin/sh
RECEIPT_FILE1=/var/db/receipts/com.apple.pkg.DevSDK.bom
RECEIPT_PLIST1=/var/db/receipts/com.apple.pkg.DevSDK.plist
RECEIPT_FILE2=/var/db/receipts/com.apple.pkg.clang.bom
RECEIPT_PLIST2=/var/db/receipts/com.apple.pkg.clang.plist
RECEIPT_FILE3=/var/db/receipts/com.apple.pkg.llvm-gcc4.2.bom
RECEIPT_PLIST3=/var/db/receipts/com.apple.pkg.llvm-gcc4.2.plist
RECEIPT_FILE4=/var/db/receipts/com.apple.pkg.DeveloperToolsCLI.bom
RECEIPT_PLIST4=/var/db/receipts/com.apple.pkg.DeveloperToolsCLI.plist
if [ ! -f "$RECEIPT_FILE4" ]
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_FILE1 $RECEIPT_FILE2 $RECEIPT_FILE3 $RECEIPT_FILE4 | sudo xargs -I{} rm -r "{}"
# remove the receipt
sudo rm $RECEIPT_FILE1 $RECEIPT_FILE2 $RECEIPT_FILE3 $RECEIPT_FILE4
# remove the plist
sudo rm $RECEIPT_PLIST1 $RECEIPT_PLIST2 $RECEIPT_PLIST3 $RECEIPT_PLIST4
echo "Done! Please restart XCode to have Command Line Tools appear as uninstalled."
curl "https://gist.github.com/yoneken/3284561/raw/db665bb64f93e38ce138b5ca620b9edd18dc31e4/remove_CLI_tools.sh" | sh
如果一切正常,您可以打开Xcode并查看命令行工具是否已安装。
然后,根据您的需求,您可以将Xcode降级到较低的版本并重新安装该版本的命令行工具,例如。
如要降级Xcode,请参考这个SO答案所述:
/Applications
并删除Xcode应用程序。当我尝试卸载命令行工具v6时,我偶然发现了这个问题。
我已经安装了完整的Xcode 6,但是将Xcode移到垃圾箱并没有卸载/删除CLT。例如,我仍然拥有/usr/bin/clang
。解决方法是手动删除CLT,使用.bom内容(类似于@veducm的答案):
cd /
lsbom -fls /var/db/receipts/com.apple.pkg.CLTools_Executables.bom | sudo xargs -I{} rm -rf "{}"
lsbom -fls /var/db/receipts/com.apple.pkg.DevSDK_OSX109.bom | sudo xargs -I{} rm -rf "{}"
sudo rm /var/db/receipts/com.apple.pkg.{CLTools_Executables,DevSDK_OSX109}.{bom,plist}
DevSDK_OSX109
替换为您拥有的版本。您可能有多个版本,如果是这样,请对所有版本应用相同的命令(例如,我既安装了Mavericks又安装了Yosemite,因此我同时拥有DevSDK_OSX109
和DevSDK_OSX1010
)。lsbom -fls /var/db/receipts/com.apple.pkg.CLTools_Executables.bom
等来查看它们的内容。cd /
。您也可以通过简单地执行rm -rf /Library/Developer/CommandLineTools
来删除CLT。rm命令用于删除文件或目录。
从以下命令中删除CLT。
sudo rm -rf /Library/Developer/CommandLineTools
从终端中执行。