How to uninstall Xcode and clear its junk completely

Jun 27, 2023#xcode#how-to#ios

Xcode is an integrated development environment (IDE) created by Apple. It is primarily used for developing software for Apple platforms such as macOS, iOS, iPadOS, watchOS, and tvOS. Xcode provides a comprehensive set of tools, including a code editor, debugging tools, interface builder, and simulators for testing applications. It supports multiple programming languages such as Swift, Objective-C, C++, and more.

xcode junk

The heaviness and space usage of Xcode can be attributed to the inclusion of various SDKs, simulators, documentation, and support for multiple programming languages. Additionally, Xcode also keeps a local cache of built products and intermediate files, which can contribute to its overall disk space usage.

Warningsâť—

These instructions mostly written for software developers when they know how to use Terminal and willing to take the risks of removing files manually by themselves. You may want to backup your important projects and data before deleting any Xcode files.

Before going through all troubles, consider using a third-party app like CleanMyMac to scan your system for Xcode junk files and delete them with one click. It’s safe and easy for anyone.

Clear Xcode junk only

Xcode can take up a lot of space on your Mac because it supports multiple operating systems and versions, and it stores a lot of data and files that you may not need anymore. Here are some tips to free up space by removing unnecessary Xcode junk:

  • Delete old simulators and devices that you don’t use anymore by going to “Window > Devices and Simulators” in Xcode and right-clicking on the ones you want to remove.
  • Delete old iOS versions that you don’t support anymore by going to ~/Library/Developer/CoreSimulator/Profiles/Runtimes and moving them to the Trash.
  • Delete iOS Simulator caches by going to ~/Library/Developer/CoreSimulator/Caches and moving them to the Trash.
  • Delete derived data and app caches by going to ~/Library/Developer/Xcode/DerivedData and ~/Library/Caches/com.apple.dt.Xcode and moving them to the Trash.
  • Delete old archives by going to “Window > Organizer > Archives” in Xcode and deleting the ones you don’t need.
  • Delete old Xcode logs by going to ~/Library/Developer/Xcode/iOS DeviceSupport and ~/Library/Logs/DiagnosticReports and moving them to the Trash.
  • Delete old playground devices by going to ~/Library/Developer/XCPGDevices and moving them to the Trash.

Uninstall Xcode completely

If you really don’t need Xcode and want to free up disk space, you can completely remove Xcode and its associated files by following these steps:

  1. Backup your customizations, consider saving these files or folders before deleting anything. You may also want to backup your important projects and data before uninstalling Xcode.
~/Library/Developer/Xcode/UserData/CodeSnippets
~/Library/Developer/Xcode/UserData/FontAndColorThemes
~/Library/Developer/Xcode/UserData/KeyBindings
~/Library/Developer/Xcode/Templates
~/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/MobileDevice/Provisioning Profiles
  1. Delete the Xcode app from the Applications folder by dragging it to the Trash or right-clicking and choosing “Move to Trash”.

  2. Delete the Xcode preferences files from the Library folder by using these commands in Terminal:

rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
rm -rf /Library/Preferences/com.apple.dt.Xcode.plist
  1. Delete the Xcode caches, support files, and simulator files from the Library folder by using these commands in Terminal:
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer
rm -rf ~/Library/MobileDevice
rm -rf ~/Library/Developer/XCTestDevices

Be careful when deleting files from the system directory, such as /Library/Developer/, and do not delete the PrivateFrameworks subfolder, as it may cause your new Xcode installation to crash.

  1. Empty the Trash to remove all the Xcode files permanently.