DEV Community

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

Posted on

1 1 2 1 2

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

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

For builders shipping the next wave of software

For builders shipping the next wave of software

Whether it's agents, tools, or something brand new, Kinde gives you auth and billing that scale with your vision.

Get a free account

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

Announcing the First DEV Education Track: "Build Apps with Google AI Studio"

The moment is here! We recently announced DEV Education Tracks, our new initiative to bring you structured learning paths directly from industry experts.

Dive in and Learn

DEV is bringing Education Tracks to the community. Dismiss if you're not interested. ❤️