Wiping out the development environment

Will the three commands

  1. sudo rm -fr /Applications/Xcode.app/
  2. sudo rm -fr /Library/Developer/
  3. rm -fr ~/Library/Developer/

completely and safely discard the development environment on macOS for a once-a-decade start-from-fresh-during-major-release upgrade of macOS?

Update

Rather than delete, I renamed the folders in question. The folders have been refilled just fine during update to Big Sur, but renaming, and hence presumably also deleting, is problematic. I am now in an infinite loop of getting the messages "An update is available for your Mac", "Command Line Tools for Xcode 12.4". Yet after clicking "Update Now" and waiting for its completion, the message returns, and another update proceeds, downloading seemingly from scratch.

Update 2

Although /usr/bin/git --version says xcodebuild: error: SDK "macosx10.15" cannot be located., git: error: .. failed, and xcode-select: Failed to locate 'git', requesting installation of command line developer tools., running sudo /usr/bin/git --version runs fine (and reports git version 2.24.3 (Apple Git-128)).

The problem then appears to be that after renaming (and even now that I've restored the renaming) the license agreement is marked as not signed, but git doesn't say so.

Update 3

(Re-)Agreeing to the license agreement from the Terminal by running sudo xcodebuild -license does not help. /usr/bin/git still says "macosx10.15" cannot be located. and xcode-select: Failed to locate 'git'.

And agreeing under the sudo identity is indeed necessary. Attempting xcodebuild -license gives Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.


Solution 1:

No, I wouldn't recommend using that method. At the same time, you're risking deleting too much, and not actually deleting the whole thing.

For quite some time now, Xcode can actually be uninstalled simply by dragging the Xcode app from the Applications folder and into the Trash. This will quite significantly delete most of its footprint.

On older systems, you could also open a Terminal and run the following command to uninstall Xcode developer tools:

sudo /Developer/Library/uninstall-devtools –mode=all

Solution 2:

These days, yes (almost). Xcode has been self-contained for years and you’ve got most of the directories. The only bits you’re missing are com.apple.dt.* files in:

  • ~/Library/Preferences
  • /Library/LaunchDaemons
  • /Library/PrivilegedHelperTools