Uninstalling Xcode on macOS is not as simple as dragging the app to the Trash. When you need to reinstall Xcode from scratch, free up tens of gigabytes, or fix persistent build errors, deleting just the main application is not enough. The system leaves behind caches, simulators, command line tools, and preferences spread all over the disk.
In this guide you will find all available methods to completely remove Xcode on macOS: from manual removal via Finder, through Terminal commands, to an automated script that deletes every last remnant. Choose the method that best fits your situation.
How to uninstall Xcode development tools on Mac, here is a complete guide on how to clean Xcode junk files, completely delete Xcode, or erase all configurations of this program from your Mac
Sometimes we need to uninstall the previous version of Xcode and install the new version. It is difficult to go one by one and delete the files and directories related to Xcode
In this article, we have prepared a shell script that will help you completely uninstall Xcode from your system.
We recommend that you read the full article; the files below are for reference only at the end of this article, where we provide the Shell script file to uninstall Xcode. What you need to do is run a single terminal command that we explain at the end of this article, which will help you completely remove Xcode from your system.
Why you need to uninstall Xcode properly
Xcode is essential for developing apps on iOS, macOS, watchOS, and tvOS, but it is also one of the heaviest applications in the Apple ecosystem. A careless installation can easily take up between 30 and 100 GB on your disk. There are several common scenarios where you will want to remove it completely:
Upgrade to a new version without errors
You try to update Xcode from the App Store and the process fails, or the new version displays strange errors right from the first launch. In most cases, the source of the problem is leftovers from previous installations: .plist files with incompatible configurations, corrupt build caches, or simulators from an outdated version clashing with new ones.
The solution is to completely uninstall Xcode before installing it again: that way you start from scratch and conflicts disappear.
Free up disk space and junk files
Depending on usage time, generated projects, and downloaded simulators, Xcode can hoard a massive amount of storage. The bulk of the consumption is usually distributed across:
- Build caches (DerivedData), which alone can exceed 10–20 GB
- iOS, watchOS, tvOS, and visionOS simulators, each several gigabytes in size
- Xcode Command Line Tools installed independently
- Old builds and cached LLVM modules
- Device support files for older iOS versions
A complete uninstallation of Xcode can recover between 20 and 100 GB of free space, sometimes more.
Performance issues and corruption
Errors like "Xcode cannot run using the selected device", simulator crashes, or the compiler refusing to accept new commands are usually signs that an internal Xcode component is corrupted. Reinstalling from scratch after a clean uninstall is the fastest way to fix it.
Methods to uninstall Xcode on macOS
There are four primary ways to remove Xcode. Each has a different scope. Here is an explanation of what each method deletes and when to use it.
Method 1: Removal via Finder (basic)
It is the fastest method, but also the least thorough. Steps:
- Open Finder → Applications
- Locate Xcode.app
- Drag it to the Trash or right-click → Move to Trash
- Empty the Trash
What does it not remove? Caches, user preferences, developer tools, simulators, and all files in ~/Library and /Library. Use it only if you simply want to remove the icon from Applications and are not concerned about space or a clean reinstall.
Method 2: Remove Xcode using xcode-select
xcode-select is Apple's official tool to manage Command Line Tools. If you only installed the command line tools (without the full Xcode app), this is the correct command to remove them:
sudo rm -rf /Library/Developer/CommandLineToolsTo verify whether you have them installed before deleting:
xcode-select -pIf the command returns a path, the tools are installed. After deleting them, you can reinstall them at any time with:
xcode-select --installImportant: this method only removes the Command Line Tools, not the Xcode.app application or its caches. Combine it with the steps in Method 4 for a complete cleanup.
Method 3: Manually remove iOS simulators
Simulators are one of the biggest space consumers and are not automatically deleted when Xcode is removed. You can delete them directly from the Terminal:
# List all available simulators
xcrun simctl list
# Delete only unavailable simulators (no associated device)
xcrun simctl delete unavailable
# Delete all simulators (requires Xcode to be installed)
xcrun simctl delete allIf you have already uninstalled Xcode and want to delete the simulators folder directly:
rm -rf ~/Library/Developer/CoreSimulator/DevicesThis can free up several gigabytes without needing to touch the main app.
Method 4: Uninstall Xcode completely using a script (recommended)
This is the most thorough method. A single Shell script closes Xcode, cleans build caches, deletes the app, removes simulators, tools, and all known remnants on the system.
⚠️ Important: this process is irreversible. Save your projects and perform a backup before continuing.
What the script deletes exactly
/Applications/Xcode.app— the main application- LLVM build caches and DerivedData
~/Library/Developer— user development folders~/Library/MobileDevice— iOS device support~/Library/Caches/com.apple.dt.Xcode— app caches.plistfiles for user and system preferences- System package receipts (BOM and PLIST)
xcode-uninstall.sh Script
#!/bin/bash
# Close Xcode if it is open
killall Xcode 2>/dev/null
# Invalidate xcrun cache and clean builds
xcrun -k
xcodebuild -alltargets clean 2>/dev/null
# Delete LLVM module caches
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
# Delete the main app
rm -rf /Applications/Xcode.app
# Delete user data
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer
rm -rf ~/Library/MobileDevice
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
rm -rf ~/Library/Preferences/com.apple.dt.xcodebuild.plist
# Delete system files (requires sudo)
sudo rm -rf /Library/Developer/CommandLineTools
sudo rm -rf /Library/Preferences/com.apple.dt.Xcode.plist
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.bom
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.plist
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.bom
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.Xcode.bom
echo "✅ Xcode completely removed from the system."How to run the script step by step
- Open Terminal (you can search for it with Spotlight: ⌘ + Space → "Terminal")
Create the script file:
nano xcode-uninstall.shPaste the content above, save with Ctrl+O, and exit with Ctrl+X.
Grant execution permissions:
chmod +x xcode-uninstall.shRun the script:
bash xcode-uninstall.sh
The script will prompt you for your administrator password for the sudo commands. In a matter of minutes, Xcode will be completely gone from the system.
Where Xcode stores its files on macOS
To understand why manual uninstallation is often incomplete, here are all the paths that Xcode typically uses:
Paths in the user directory
~/Library/Developer/— main development data~/Library/Developer/CoreSimulator/— iOS/watchOS/tvOS simulators~/Library/Developer/Xcode/DerivedData/— compiled builds~/Library/Caches/com.apple.dt.Xcode/— app cache~/Library/MobileDevice/— support for physical devices~/Library/Preferences/com.apple.dt.Xcode.plist— user preferences~/Library/Preferences/com.apple.dt.xcodebuild.plist— build preferences
System paths
/Applications/Xcode.app— the main application/Library/Developer/CommandLineTools/— command line tools/Library/Preferences/com.apple.dt.Xcode.plist— global preferences/System/Library/Receipts/com.apple.pkg.Xcode*.bom— installer logs/private/var/db/receipts/com.apple.pkg.Xcode.bom— additional system receipt
What to do after uninstalling Xcode
Verify that no remnants remain
Once the script has been executed, perform these checks before reinstalling:
- Restart your Mac to clear memory processes
Verify that the app does not exist:
ls /Applications/Xcode.appIt should return a "No such file or directory" error.
Check that
xcode-selectdoes not point to any active directory:xcode-select -pIf it returns a path, reset it with:
sudo xcode-select -r
How to reinstall Xcode properly
With a clean system, reinstallation is straightforward and surprise-free:
- Open the App Store on your Mac
- Search for "Xcode" and select Apple's official app
- Click Get / Install
- Upon opening Xcode for the first time, accept the installation of additional components
Optionally, reinstall the Command Line Tools:
xcode-select --install
Reinstalling after a complete cleanup is noticeably smoother: no license errors, no conflicts with old settings, and no failures on the first build.
You can also use Mole, a terminal tool to clean, optimize, and uninstall applications on macOS, including Xcode and its leftovers.
Frequently asked questions about uninstalling Xcode on Mac
- What happens if I delete Xcode?
- You will no longer be able to compile apps for the Apple ecosystem until you reinstall it, but the operating system and all other applications will function normally.
- Can Xcode be uninstalled without losing projects?
- Yes. The script deletes the app and its system files, but it does not touch your projects folder (by default in
~/Documentsor wherever you have saved them). Your.xcodeprojfiles and source code remain intact.
- Yes. The script deletes the app and its system files, but it does not touch your projects folder (by default in
- Is it safe to use Terminal to remove Xcode?
- Yes, as long as you know what you are running. The script in this guide only removes known Xcode paths and does not touch other parts of the system.
- How much space does completely uninstalling Xcode free up?
- It depends on accumulated usage, but recovering between 20 and 80 GB is common. If you have several simulators and a lot of accumulated DerivedData, it can exceed 100 GB.
- Can I reinstall Xcode after using the script?
- Yes, without any problem. In fact, installing Xcode on a clean base prevents most of the typical errors encountered on initial launch.
- Does the script also delete the Command Line Tools?
- Yes, the improved version of the script includes
sudo rm -rf /Library/Developer/CommandLineTools. You can reinstall them at any time withxcode-select --install.
- Yes, the improved version of the script includes
- Does it work on Apple Silicon (M1, M2, M3, M4)?
- Yes. The installation paths for Xcode are the same on Apple Silicon and Intel Macs. The script works on both architectures.
Conclusion
Uninstalling Xcode properly on macOS makes the difference between dragging issues along for months or starting with a clean and stable installation. Depending on your situation, you can choose between:
- Removing only the app from Finder if you do not need to reclaim space
- Deleting Command Line Tools with
xcode-selectif you only have those - Selectively cleaning simulators with
xcrun simctl delete unavailable - Using the full script for a complete uninstallation before reinstalling
If you need to reinstall Xcode without errors or urgently free up space on your Mac, the script in this guide is the fastest, most complete, and most controlled way to do it.