Deleting Xcode DerivedData, and the 40 GB Around It
Every iOS developer eventually discovers ~/Library/Developer is consuming 50 GB. DerivedData gets the blame, but it is rarely the largest offender. Here is the full map.
Xcode is the single largest consumer of disk space on most developer Macs, and almost all of it is regenerable. The catch is that the folders differ in what they cost you to delete, one is free, one costs a long rebuild, and one costs a multi-gigabyte re-download.
The folders, by size and by risk
DerivedData, delete freely
~/Library/Developer/Xcode/DerivedData
Build products, module caches, and index data for every project you've ever opened. Typically 5–30 GB. Entirely safe to delete: Xcode rebuilds it. The only cost is that your next build is a full one, and the index has to rebuild before code completion and jump-to-definition work again.
Deleting DerivedData is also the standard fix for a whole class of nonsense Xcode errors, stale module caches, “no such module” when the module plainly exists, and phantom build failures that survive a clean.
iOS DeviceSupport, usually the biggest surprise
~/Library/Developer/Xcode/iOS DeviceSupport
Symbol files downloaded from every physical device you've ever plugged in, kept per iOS version. Each is 1–4 GB and they're never cleaned up. On a machine used for a few years this folder alone commonly holds 20–40 GB.
Safe to delete. The cost: the next time you connect a device running that iOS version, Xcode re-copies the symbols, which takes a few minutes.
Simulator runtimes and devices, big, deletable, but re-downloaded
~/Library/Developer/CoreSimulator/Devices
Every simulator you ever created, including ones from Xcode versions you've uninstalled. Each runtime is several gigabytes.
Prefer the supported route rather than deleting by hand:
xcrun simctl delete unavailable
That removes simulators whose runtimes no longer exist, the safest, highest-yield command in this entire article. To see what you've:
xcrun simctl list devices Archives, check before you delete
~/Library/Developer/Xcode/Archives
This is the one to be careful with. Archives contain the dSYM files needed to symbolicate crash reports from builds you've already shipped. Delete the archive for a released build and you lose the ability to read its crash logs.
Delete old archives for builds that never shipped. Keep anything corresponding to a release.
simctl. Archives: check first, because shipped builds need their dSYMs.
Beyond Xcode
The same accumulation happens across every toolchain:
- npm / yarn / pnpm:
~/.npm,~/Library/Caches/Yarn, and the pnpm store. Clear withnpm cache clean --force. - CocoaPods:
~/Library/Caches/CocoaPods, frequently several gigabytes. - Gradle:
~/.gradle/caches, which grows without limit on Android projects. - pip:
~/Library/Caches/pip. - Homebrew: old downloads, cleared with
brew cleanup --prune=all. - Docker: usually the largest of all if you use it.
docker system prune -a, understanding that it removes unused images.
Every one of these regenerates. Collectively they routinely account for another 10–30 GB.
Reclaim all of it in one pass
CleanMachine's Developer Cache Cleaner finds Xcode, CocoaPods, npm, Gradle, pip, Homebrew and Docker caches together, shows the size of each, and lets you clear them selectively. Free to scan and see the totals.
↓ Download Free & ScanA note on rm -rf
The usual advice is rm -rf ~/Library/Developer/Xcode/DerivedData/*. It works. Two cautions: quit Xcode first, or it'll rewrite state as you delete it; and be exact with the path, because a mistyped rm -rf in your home directory is unrecoverable. Moving the folder to the Trash is slower and strictly safer.