Xcode is usually the single largest consumer of disk space on a Mac used for development, and most of what it keeps is disposable. The trick is knowing which parts regenerate for free, which cost you a long rebuild, and which are not caches at all.
Safe to delete, regenerates for free
- ~/Library/Developer/Xcode/DerivedData. Build intermediates, indexes, and module caches. Deleting it costs a full rebuild and a reindex, nothing more. This is almost always the biggest item.
- ~/Library/Caches/com.apple.dt.Xcode. Xcode's own cache directory, regenerated on next launch.
- ~/Library/Developer/Xcode/Archives, if you have already shipped or exported everything you need. Archives are how you re-symbolicate old crash reports, so keep the ones matching builds still in the wild.
- ~/Library/Developer/CoreSimulator/Caches. Simulator caches, regenerated on demand.
Costly but recoverable
iOS DeviceSupport under ~/Library/Developer/Xcode/iOS DeviceSupport holds symbol files for every OS version of every device you have ever plugged in. It can reach tens of gigabytes. Deleting it is safe, but Xcode re-copies the symbols the next time you attach a device running that version, which takes several minutes per device.
Unused simulator runtimes are similar. Each runtime is several gigabytes and can be removed and redownloaded:
xcrun simctl delete unavailable
xcrun simctl list runtimes
Do not delete
Keychain entries for signing identities, provisioning profiles under ~/Library/MobileDevice/Provisioning Profiles, and anything under ~/Library/Developer/Xcode/UserData are not caches. UserData holds your breakpoints, snippets, and window layouts. Provisioning profiles can be redownloaded but only from an account with the right access, which is a bad surprise mid-release.
A note on the manual approach
The common advice is a blanket rm -rf on DerivedData. That works, but it also deletes the index for every project at once, and gives you no idea how much you actually reclaimed or which project was responsible. If one project is holding 40 GB of build output, it is worth knowing which.
Burrow's Purge tool separates developer artifacts from ordinary caches and shows the rebuild cost of each category, so you can drop a 30 GB DerivedData directory while leaving a package cache that would take twenty minutes to refetch. Everything is listed with real byte counts before it is removed.