How to clear Xcode DerivedData and other Xcode caches
Xcode stores build products, simulator data and old device symbols in your Library folder and never cleans them up on its own. On a Mac that has done iOS work for a year or two, they can take up a large share of the disk.
DerivedData
DerivedData holds build products, indexes and logs for every project you have opened. It lives at ~/Library/Developer/Xcode/DerivedData. It is safe to delete, because Xcode rebuilds it. The next build will be slower while Xcode builds and indexes again.
Quit Xcode first, then run:
rm -rf ~/Library/Developer/Xcode/DerivedData
You can also open the folder from Xcode: Settings, then Locations, then click the small arrow next to the DerivedData path.
Simulators
Old simulators for runtimes you no longer have installed can be removed with one command:
xcrun simctl delete unavailable
The folder ~/Library/Developer/CoreSimulator/Caches is rebuilt on demand. ~/Library/Developer/CoreSimulator/Devices is different: it holds the apps and data inside each simulator, so deleting it wipes whatever you installed or saved there.
Device support files
When you connect an iPhone or Apple Watch, Xcode copies debug symbols for its OS version into iOS DeviceSupport and watchOS DeviceSupport, one folder per version. They are downloaded again the next time you connect a device that needs them, which takes a few minutes. Removing the versions you no longer test on is reasonable.
Archives
The Archives folder holds the builds you archived for distribution. You need them to symbolicate crash reports from released versions and to upload from the Organizer. Do not delete them without a reason, and check that you no longer need them first.
Quick reference
| Folder in ~/Library/Developer | What it is | Delete? |
|---|---|---|
| Xcode/DerivedData | Build products and indexes | Yes, it is rebuilt |
| CoreSimulator/Caches | Simulator caches | Yes, it is recreated |
| Xcode/iOS DeviceSupport | Debug symbols per OS version | Yes, but it is downloaded again |
| Xcode/Archives | Archived builds | Only if you do not need them |
| CoreSimulator/Devices | Simulators and their app data | Only if you can lose that data |
Doing it with Vervain
Vervain's System Junk module lists these under Xcode and labels each one. DerivedData and simulator caches are marked safe, device support files are marked review, and Archives and simulator devices are marked risky. Risky items are never ticked by default. Anything you remove goes to the Trash, so you can still change your mind.