Home / Guides / How to Clear Xcode DerivedData and Free Space on Mac
How to clear Xcode DerivedData (and other Xcode leftovers) on Mac
Quick answer: quit Xcode, then delete ~/Library/Developer/Xcode/DerivedData. Xcode recreates it on the next build. It is the safest and usually the biggest Xcode cleanup.
What DerivedData is
Every time you build, Xcode stores compiled products, indexes, build logs and intermediate files in DerivedData, one subfolder per project. On an active machine with several projects it grows steadily, and it is never cleaned up automatically. Because Xcode can regenerate all of it, it is the first thing to remove.
Delete it
From Xcode: open Settings → Locations, click the small arrow next to the Derived Data path to reveal it in Finder, quit Xcode and move the folders to the Trash. Or in Terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
Expect the first build and the first indexing afterwards to take longer than usual.
See how much Xcode is using
du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator 2>/dev/null
On a lightly used test Mac this showed DerivedData at 391 MB, iOS DeviceSupport at 555 MB and CoreSimulator at 2.8 GB. On a Mac that builds large apps every day each of them can be many times bigger.
The other Xcode folders and what to do with each
| Folder | What it is | Safe to delete? |
|---|---|---|
| ~/Library/Developer/Xcode/DerivedData | Build products, indexes and logs | Yes. Rebuilt on the next build |
| ~/Library/Developer/Xcode/iOS DeviceSupport (also watchOS and tvOS) | Debug symbols copied from devices you connected | Yes. Copied again when you reconnect the device |
| ~/Library/Developer/Xcode/Archives | Archived builds with their dSYM files | Only the ones you no longer need to submit or symbolicate |
| ~/Library/Developer/CoreSimulator/Devices | Simulator devices with their apps and data | Delete unused devices. Apps inside lose their data |
| ~/Library/Developer/CoreSimulator/Caches | Simulator caches | Yes |
| ~/Library/Caches/org.swift.swiftpm | Swift Package Manager cache | Yes. Packages are fetched again |
| ~/Library/Caches/CocoaPods | CocoaPods cache | Yes. Or run pod cache clean --all |
Old simulators and runtimes
Simulators are often the second biggest item. This removes simulator devices that the installed Xcode can no longer use:
xcrun simctl delete unavailable
Simulator runtimes (the downloadable iOS, watchOS and tvOS images) are usually several gigabytes each. List them, then preview what a cleanup would remove before you delete anything:
xcrun simctl runtime list
xcrun simctl runtime delete --notUsedSinceDays 30 --dry-run
If the preview looks right, run the same command without --dry-run. You can also remove runtimes in Xcode under Settings → Components (called Platforms in some earlier versions).
What not to do
- Do not delete the whole
~/Library/Developerfolder. It also holds things you may want, such as your Archives. - Do not delete Archives without checking that you will never need their dSYM files again.
- Do not run
rm -rfwithsudoon any of these paths. None of them needs administrator rights. - Quit Xcode and the Simulator before deleting.
Let a tool sort it for you
See Your Disk shows these folders on a map and marks DerivedData, device support files and simulator caches as Safe, while Archives and simulator devices are marked Review. See how it decides and the wider System Data cleanup guide.
A map of your Mac's disk, and a safe way to clean it.
Frequently asked questions
Is it safe to delete DerivedData?
Yes. DerivedData only holds build products, indexes and logs that Xcode creates again the next time you build. Quit Xcode first. The first build afterwards is slower because everything is rebuilt.
Will deleting DerivedData fix Xcode build errors?
Often it fixes problems caused by stale build products or a stale index, which is why it is a common first step. Product, Clean Build Folder (Shift-Command-K) is the milder version of the same idea. Neither is guaranteed to fix every error.
Can I delete the iOS DeviceSupport folder?
Yes. It holds debug symbols that Xcode copies from a device the first time you connect it with a given OS version. Xcode copies them again when you reconnect, which takes a few minutes.
Which Xcode folder should I never delete without checking?
Archives. It contains your archived builds including their dSYM files, which you need to symbolicate crash reports for versions already released. Remove only archives you will never need again.
Related guides
- How to clear System Data on Mac safely: Step-by-step, from safest to most effort, with the Terminal commands and the things you should not delete.
- Docker.raw looks huge on Mac: how to see the real size and reclaim space: Why Docker.raw can look like hundreds of gigabytes, how to see the real size, and how to reclaim space without losing data.
- How See Your Disk cleans: methods and safety levels: A transparent explanation: rules instead of guesses, three safety levels and what is never touched.