Skip to content
← All posts

Clear Xcode DerivedData and old simulators safely

If you build iOS or macOS apps, Xcode is probably the biggest reason your Mac keeps running out of space. Most of it is not Xcode itself but what it leaves behind: build data for every project you ever opened, simulator devices full of test installs, and runtimes for iOS versions you stopped testing on years ago.

All of it can be cleared safely if you know which folder is which. This post covers each one, the commands to clear it, and what to keep.

Check what Xcode is using first

Before deleting anything, see where the space actually is. This prints the size of each Xcode folder in your home folder:

du -sh ~/Library/Developer/Xcode/DerivedData \
  ~/Library/Developer/Xcode/Archives \
  ~/Library/Developer/Xcode/"iOS DeviceSupport" \
  ~/Library/Developer/CoreSimulator/Devices 2>/dev/null

Simulator runtimes are not in your home folder. List them, with their size, using xcrun simctl runtime list -v, or open Xcode › Settings › Components.

DerivedData: safe to delete, any time

~/Library/Developer/Xcode/DerivedData holds intermediate build products, indexes and logs, one folder per project. Xcode recreates everything in it on the next build. The only cost is that the next build and the first indexing run take longer.

Quit Xcode first, then:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

To clear just one project, delete its folder inside DerivedData (they are named after the project plus a hash), or use Product › Clean Build Folder in Xcode while that project is open. If you changed the DerivedData location, Xcode › Settings › Locations shows where it is.

Deleting DerivedData is also the classic fix for strange build errors and a stuck indexer, so it is worth knowing even when you have plenty of space.

Simulator devices

Every simulator device you create has its own folder in ~/Library/Developer/CoreSimulator/Devices, with the apps you installed and the data they wrote. Two kinds pile up:

Remove all unavailable devices with one command:

xcrun simctl delete unavailable

To remove a device you no longer need, find its ID and delete it:

xcrun simctl list devices
xcrun simctl delete <device-id>

If you want to keep a device but throw away the apps and data inside it, erase it instead. It must be shut down first:

xcrun simctl erase <device-id>

Avoid xcrun simctl delete all and xcrun simctl erase all unless you really mean it: they remove or reset every device, including the one you test on every day.

Simulator runtimes: the biggest win

Runtimes are the iOS, watchOS, tvOS and visionOS system images that simulators boot from. Each one is several gigabytes, and they stay installed after you stop using them.

List them first:

xcrun simctl runtime list

Then delete what you don’t need. --dry-run shows what would go without deleting anything:

xcrun simctl runtime delete --notUsedSinceDays 90 --dry-run
xcrun simctl runtime delete --notUsedSinceDays 90

You can also delete runtimes that can no longer be used with --unusable, or a single one by its identifier. Xcode › Settings › Components does the same thing with a button.

Keep the runtime for the lowest iOS version your app supports if you still test on it. You can download any runtime again later from the same Components pane, but it is a large download.

Device support files

When you connect an iPhone or iPad and run on it, Xcode copies debug symbols for that exact iOS version into ~/Library/Developer/Xcode/iOS DeviceSupport. A new folder appears for every iOS update, and the old ones are never removed.

Folders for iOS versions none of your devices run anymore can go. Delete them in Finder, or with rm -rf on the specific folder. Quote the path, because the folder names contain spaces: rm -rf ~/Library/Developer/Xcode/"iOS DeviceSupport"/"<version folder>". If you connect a device with that version again, Xcode copies the files again, which takes a few minutes.

Archives: delete with care

~/Library/Developer/Xcode/Archives holds every build you archived for TestFlight or the App Store. They are the one Xcode folder you should not clear blindly: an archive contains the debug symbols (dSYMs) you need to read crash reports from that release.

Open Window › Organizer › Archives in Xcode, and delete archives of versions you no longer support. Keep the ones for releases people still run, unless your dSYMs are stored elsewhere, for example uploaded to your crash reporting service.

Caveats

The faster way: CCToolify

Smart Clean in CCToolify finds DerivedData, simulators, simulator caches, SwiftUI Previews, device support files and archives in one read-only scan, together with package manager caches, and shows how much space each one takes.

Simulator runtimes are not part of Smart Clean: delete those with xcrun simctl runtime delete or in Xcode › Settings › Components, as shown above.

On our own dev MacBook, one clean freed 193.62 GB. The Disk Scan guide walks through it step by step.