Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

xcode5 - How do I uninstall xcode 5 command line tools?

I upgraded to xcode 5 Command Line Tools on Friday. Something is not working correctly and I want to go back to the last 4.x version ox xcode. How do I uninstall xcode 5 command line tools? I don't see anything in the release notes.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Depending on whether you are running Xcode 5 in Mavericks or not, you will need to do two different things to uninstall the command line tools.

  • 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."
    

You can run this easily by opening a Terminal and running this command (it will download the script and execute it automatically):

curl "https://gist.github.com/yoneken/3284561/raw/db665bb64f93e38ce138b5ca620b9edd18dc31e4/remove_CLI_tools.sh" | sh

If everything worked fine, you could open Xcode and see that the Command Line Tools appear as to be installed.

Then, depending on what you want, you could downgrade Xcode to a lower version and reinstall the Command Line Tools for that version, for example.

To downgrade Xcode, as explained in this SO answer:

  1. Uninstall Xcode 5: go to /Applications and delete the Xcode app.
  2. Restart the Mac.
  3. Then you can download the desired Xcode version from here and install it from scratch.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...