如何彻底卸载 OS X 开发人员工具?

如何彻底卸载 OS X 开发人员工具?

我的 Mac 上安装了 Apple 的开发工具,但有些链接异常导致某些二进制文件无法运行。重新安装 Xcode 及其命令行工具(无论是公共版本 4 还是开发人员预览版本 5)都无法解决这个问题。我该如何彻底删除命令行工具,以便重新干净地安装它们?

答案1

正如 Cocoanetics 所述 这里,你可以使用此脚本彻底删除该工具:

删除命令行工具

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.

相关内容