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 dozens of gigabytes, or fix persistent errors, deleting only the main application is not enough.
In my case, I had to uninstall an old version of Xcode to install a new one and encountered the usual problem: files and folders scattered throughout the system. Going one by one is slow, confusing, and easy to do wrong. That's why in this guide I explain how to uninstall Xcode completely, which files each method deletes, and how to do it quickly and safely using a script.
How to uninstall Xcode development tools on Mac; here is a complete guide on how to clean up Xcode junk files, completely remove Xcode, or delete 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 only for reference at the end of this article, we provide you with the Shell script file to uninstall Xcode. What you should do is run a single terminal command that we explain at the end of this article and it will help you completely remove Xcode from your system.
Why Uninstalling Xcode on Mac May Be Necessary
Xcode is an essential tool for developing on macOS, iOS, watchOS, or tvOS, but it is also one of the applications that consumes the most space on a Mac.
Problems when Updating or Reinstalling Xcode
One of the most common scenarios is this: you try to update Xcode from the App Store and it fails, or the new version gives strange errors. In many cases, the problem is not the app itself, but remains of previous installations.
When I went through this, deleting Xcode and reinstalling it didn't solve anything… until I deleted all the associated files. That's when I understood that an incomplete uninstallation is usually the cause.
Disk Space and Junk Files
Depending on the projects, simulators, and versions installed, Xcode can occupy dozens or even more than 100 GB. Much of that space is in:
- Caches
- Old builds
- Command Line Tools
- Simulators you no longer use
Correctly removing Xcode can free up an enormous amount of space in just a few minutes.
Methods to Uninstall Xcode on macOS
There are several ways to do it. They all work, but not all of them remove Xcode completely.
Manual Removal (Finder + Library)
- It is the most basic method:
- Open Finder → Applications
- Drag Xcode.app to the Trash
- Empty the Trash
This deletes the main application, but does not delete:
- Caches
- Preferences
- Development Tools
- Simulators
- Files in ~/Library and /Library
It serves only as a first step, never as a complete solution.
Uninstall Xcode Using Terminal
Using Terminal allows you to remove more remains, but it has two problems:
- You have to run many commands
- It's easy to forget an important path
It normally involves manually deleting folders such as:
- ~/Library/Developer
- ~/Library/Caches/com.apple.dt.Xcode
- ~/Library/MobileDevice
- System preferences and receipts
It works, but in practice, it is slow and prone to errors, especially if you are not clear on what each command does.
Why Manual Methods Usually Fail
The problem isn't deleting Xcode, it's making sure there is absolutely nothing left that interferes with a clean reinstallation.
That's why I prepared a Shell script that automates the entire process and avoids having to go folder by folder.
How to Uninstall Xcode Completely with a Script (Recommended Method)
This is the fastest, cleanest, and most reproducible method.
The idea is simple:
A single script that closes Xcode, cleans caches, removes the app, deletes tools, and removes all known remnants.
What Exactly Does the Script Delete
The script deletes:
- The application /Applications/Xcode.app
- Build caches
- Developer folders
- Simulators
- User and system preferences
- Xcode receipts on macOS
It is exactly what I use when I need to start from scratch before reinstalling.
Script to Uninstall Xcode on macOS
⚠️ Important: make a backup before continuing. This process is irreversible.
For complete removal of Xcode, delete the following:
xcode-uninstall.sh
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf /Applications/Xcode.app
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
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.bomHow to Run the Script Step by Step
Open Terminal
Save the script to a file, for example:
xcode-uninstall.shGive it execution permissions:
chmod +x xcode-uninstall.shRun the script:
bash xcode-uninstall.shIn a few minutes, Xcode will have completely disappeared from the system.
Warnings and Backup
- Ensure that Xcode is closed
- Do not run the script if you don't know what you are deleting
- Save important projects before continuing
This method is powerful precisely because it leaves no remnants.
Files and Folders that Xcode Leaves on Your Mac
To understand why this process works, these are the most common paths that Xcode uses:
Common paths in ~/Library and /Library
- ~/Library/Developer
- ~/Library/Caches/com.apple.dt.Xcode
- ~/Library/MobileDevice
- ~/Library/Preferences/com.apple.dt.Xcode.plist
- /Library/Preferences/com.apple.dt.Xcode.plist
Command Line Tools and Simulators
In addition to the app, Xcode installs:
- Command Line Tools
- iOS, watchOS, and tvOS simulators
- System receipts
If they are not removed, they can cause conflicts when reinstalling.
What to Do After Removing Xcode
- Restart and check that no remnants remain
- After running the script:
- Restart the Mac
- Check that /Applications/Xcode.app does not exist
- Run xcode-select -p to verify it doesn't point to Xcode
How to Reinstall Xcode Correctly
- Once the system is clean:
- Open the App Store
- Search for Xcode
- Download the latest version
- Open it and let it install the additional components
- Reinstallation usually goes much smoother after a complete cleanup.
Frequently Asked Questions About Uninstalling Xcode on Mac
- What happens if I delete Xcode?
- You will no longer be able to compile Apple apps until you reinstall it, but the system will function normally.
- Is it safe to use Terminal to remove Xcode?
- Yes, as long as you know which commands you are running. The script automates this process to reduce errors.
- How much space does uninstalling Xcode free up?
- It depends on usage, but it's not uncommon to recover 20, 50, or more GB.
- Can I reinstall Xcode later?
- Yes, no problem. In fact, this method is ideal before a clean reinstallation.
Conclusion
Uninstalling Xcode on macOS correctly makes the difference between carrying over old problems or starting from scratch. Although manual methods and third-party applications exist, using a well-defined script is the fastest, cleanest, and most controlled way to do it.
If, like me, you need to reinstall Xcode without errors or free up space urgently, this method will save you a lot of time and frustration.
I agree to receive announcements of interest about this Blog.
Learn how to completely uninstall Xcode on macOS. Step-by-step guide with a safe script to remove Xcode and all its residual files.