How to Safely Remove Xcode Without Breaking Command Line Tools (CLT)
Rodrigo Oler

Rodrigo Oler @oler

Location:
São Paulo, Brazil
Joined:
Oct 26, 2018

How to Safely Remove Xcode Without Breaking Command Line Tools (CLT)

Publish Date: Jun 17
7 1

If you once built iOS/macOS apps but no longer need Xcode — or you simply want to free up tens of gigabytes of disk space — this guide shows how to safely remove Xcode without losing Command Line Tools (CLT) that keep your terminal environment working.

Why Would You Remove Xcode?

  • Xcode occupies 10–30 GB depending on version and simulators.
  • You no longer develop for iOS/macOS.
  • You want to free SSD space but keep git, clang, make, brew, etc., functional.

Step 1: Ensure Command Line Tools (CLT) Are Installed

Before deleting Xcode, you must have CLT installed. Check with:

xcode-select -p
Enter fullscreen mode Exit fullscreen mode

If you see:

/Applications/Xcode.app/Contents/Developer
Enter fullscreen mode Exit fullscreen mode

That means the CLT isn't set.

To install CLT directly:

softwareupdate --list
Enter fullscreen mode Exit fullscreen mode

Find the latest Command Line Tools, like:

* Label: Command Line Tools for Xcode-16.4
Enter fullscreen mode Exit fullscreen mode

Then install it:

sudo softwareupdate -i "Command Line Tools for Xcode-16.4"
Enter fullscreen mode Exit fullscreen mode

Once done, verify:

xcode-select -p
Enter fullscreen mode Exit fullscreen mode

Expected:

/Library/Developer/CommandLineTools
Enter fullscreen mode Exit fullscreen mode

Now your CLI tools will work without Xcode.

Step 2: Remove Xcode Safely

To fully remove Xcode:

sudo rm -rf /Applications/Xcode.app
Enter fullscreen mode Exit fullscreen mode

Or simply drag Xcode.app to the Trash via Finder and empty the Trash.

Step 3 (Optional): Free Additional Space

Xcode leaves extra files. You can remove them:

sudo rm -rf ~/Library/Developer/Xcode
sudo rm -rf ~/Library/Caches/com.apple.dt.Xcode
sudo rm -rf ~/Library/Application\ Support/Xcode
sudo rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
sudo rm -rf ~/Library/Developer/CoreSimulator
Enter fullscreen mode Exit fullscreen mode

Warning: The last line removes all iOS simulators, if any remain.

Step 4: Reset Command Line Tools (if needed)

If xcode-select complains:

sudo xcode-select --switch /Library/Developer/CommandLineTools
Enter fullscreen mode Exit fullscreen mode

Step 5: Confirm Everything Works

Test key tools:

git --version
clang --version
make --version
Enter fullscreen mode Exit fullscreen mode

All should work fine without Xcode.

Summary

Task Command
Check CLT xcode-select -p
Install CLT via terminal sudo softwareupdate -i "Command Line Tools for Xcode-XX.X"
Remove Xcode sudo rm -rf /Applications/Xcode.app
Remove extra files rm -rf ~/Library/... (as listed above)
Set CLT path manually sudo xcode-select --switch /Library/Developer/CommandLineTools
Verify tools git --version, clang --version, make --version

Why This Is Useful

  • Saves ~20 GB of space.
  • Keeps Terminal fully working.
  • Great for backend, Python, Rust, Go, or web developers who don’t build for Apple platforms anymore.

Bonus: Automation Script

Here’s a simple shell script to automate this process:

#!/bin/bash

echo "Checking for Command Line Tools..."
if ! xcode-select -p | grep -q CommandLineTools; then
  echo "Installing Command Line Tools..."
  latest_clt=$(softwareupdate --list | grep -B 1 "Command Line Tools" | head -n 1 | awk -F'* Label: ' '{print $2}')
  sudo softwareupdate -i "$latest_clt"
else
  echo "Command Line Tools already installed."
fi

echo "Removing Xcode..."
sudo rm -rf /Applications/Xcode.app

echo "Cleaning extra files..."
rm -rf ~/Library/Developer/Xcode
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Application\ Support/Xcode
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
rm -rf ~/Library/Developer/CoreSimulator

echo "Setting Command Line Tools path..."
sudo xcode-select --switch /Library/Developer/CommandLineTools

echo "Done. Your Terminal environment is safe and clean!"
Enter fullscreen mode Exit fullscreen mode

Comments 1 total

  • Admin
    AdminJun 17, 2025

    Hey everyone! We’re launching a limited-time token giveaway for all verified Dev.to authors. Click here here to see if you qualify (instant distribution). – Dev.to Team

Add comment