Why is Xcode taking up so much space, and what can you delete?

Xcode stores build output, simulator devices, simulator runtimes, iOS device support files and app archives under ~/Library/Developer, and only some of that is rebuildable cache.

Shiva ChandraMaker of Clean House · · 4 min read
Short answer

Xcode fills a Mac mainly through DerivedData, CoreSimulator devices, simulator runtimes and iOS DeviceSupport under ~/Library/Developer. Quit Xcode, then clear DerivedData, delete unavailable simulators, remove old runtimes and old DeviceSupport folders. Leave Archives alone unless you are sure.

What is taking up space in ~/Library/Developer?

Run this to see which folders are biggest. It only reads sizes and deletes nothing:

du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator/* 2>/dev/null | sort -h

On a Mac that has run Xcode for a few years, the usual suspects are these.

FolderWhat it isCall
Xcode/DerivedDataBuild products, indexes, logsSafe to clear
Xcode/UserData/PreviewsSwiftUI preview dataSafe to clear
Xcode/iOS DeviceSupportSymbols copied from each iPhone or iPad you plugged inSafe to clear (old versions)
CoreSimulator/DevicesOne folder per simulator, with its apps and dataLook first
Simulator runtimesThe iOS, watchOS and tvOS system imagesLook first
Xcode/ArchivesBuilds you archived for distributionKeep unless you checked

The sections below go in the order that is safest, from folders that rebuild on their own to ones that hold your work.

In what order should I clear Xcode storage?

  1. Quit Xcode and the Simulator app. Deleting files while Xcode is building can corrupt a build or crash it.
  2. Clear DerivedData and Previews (the safest wins).
  3. Remove old iOS DeviceSupport folders.
  4. Delete unavailable simulators, then reset the rest if you need more.
  5. Remove simulator runtimes you no longer test on.
  6. Last, decide about Archives.

How do I delete Xcode DerivedData?

DerivedData is where Xcode puts everything it builds for a project: compiled objects, the index it uses for autocomplete, and build logs. It is rebuilt from your source, so deleting it costs time, not data. Expect a slower first build and a re-index afterward.

rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Developer/Xcode/UserData/Previews
These commands permanently delete the folders. They do not go to the Trash and cannot be undone. Both rebuild from your source code.

You can also do this from Xcode: Settings, Locations, then the arrow next to the DerivedData path to open it, and move the folders to the Trash yourself. Details on the folder are in Xcode DerivedData on Mac.

What is iOS DeviceSupport and can I delete it?

Each time you connect a device running a new iOS version, Xcode copies that version's system symbols to ~/Library/Developer/Xcode/iOS DeviceSupport, so it can debug the device. One folder per version and chip, often several gigabytes each. Old versions you no longer test on are safe to remove; Xcode copies the files again the next time you plug in such a device.

ls -lh "$HOME/Library/Developer/Xcode/iOS DeviceSupport"
rm -rf "$HOME/Library/Developer/Xcode/iOS DeviceSupport/17.2 (21C62)"

Replace the folder name in the second command with a real one from the first. The quotes matter because the folder name has spaces. This deletion is permanent. See iOS DeviceSupport for more.

How do I delete old iOS simulators?

Simulator devices live in ~/Library/Developer/CoreSimulator/Devices, one folder of apps and data per simulator. First list them, then remove the ones whose runtime is gone:

xcrun simctl list devices
xcrun simctl delete unavailable

delete unavailable removes simulators whose runtime is no longer installed. It does not touch simulators you can still boot.

If you need more space, this resets every simulator to factory state:

xcrun simctl shutdown all
xcrun simctl erase all
erase all removes the apps, app data and settings inside every simulator. The devices stay, but the contents are gone for good. If a test app keeps a local database you care about, skip this.

A simulator you are running right now should not be erased, so shut them down first. More on the folder at CoreSimulator devices.

How do I remove old simulator runtimes?

A runtime is the downloaded iOS (or watchOS, tvOS, visionOS) system a simulator runs. Each is often several gigabytes, and recent Xcode versions keep them as disk images outside your home folder, so the du command above does not count them. List and delete:

xcrun simctl runtime list
xcrun simctl runtime delete <runtime-identifier>

Copy the identifier from the list output. You can also open Xcode, then Settings, then Components, and delete a runtime there. Apple has no single page covering these commands; reports on the Apple Developer Forums show that a runtime sometimes stays stuck in a deleting state or returns after a restart. If that happens, delete it from Xcode's Components pane and restart the Mac.

Should I delete Xcode Archives?

Archives are not caches. Each .xcarchive under ~/Library/Developer/Xcode/Archives is a build you made for the App Store or for testers, and it contains the debug symbols (dSYMs) that turn crash reports into readable lines. Deleting a shipped version's archive can make its crashes hard to read later. Open Xcode's Organizer, look at the dates, and remove only archives for versions you will never need to debug. This is why Xcode Archives is a "Look first" or "Keep" call, never an automatic one.

How does Clean House handle Xcode storage?

Clean House recognizes Xcode DerivedData, iOS DeviceSupport and simulators as developer data and shows them in the Dev Desk room with a "Why?" card: which app made the folder, when it was last used, and what happens if it goes (a rebuild, or a re-download). Each item gets one call: Safe to clear, Look first or Keep. It avoids moving things in use, such as a booted simulator. Cleaning moves items to the Trash after a re-check, and Recently Cleared puts them back until you empty the Trash.

For the same job on other tools, see Gradle and Android Studio storage and node_modules disk space.

Questions

Is it safe to delete Xcode DerivedData?

Yes. DerivedData holds build products and indexes that Xcode regenerates. The next build is slower and indexing runs again, but no source code or project settings live there. Quit Xcode first.

Can I delete Xcode Archives?

Look first. Archives are not caches. Each one holds the build you submitted or shipped, including the debug symbols needed to read crash reports. Delete only versions you will never need to symbolicate.

What does xcrun simctl erase all do?

It resets every simulator to a fresh state. Apps, app data and settings inside the simulators are removed, but the simulator devices themselves stay. It does not remove old runtimes.

Why is ~/Library/Developer so big?

Usually because of CoreSimulator devices, Xcode DerivedData and iOS DeviceSupport. Each can reach tens of gigabytes on a Mac used for years, and none of them clean themselves up.

Will deleting simulators break my project?

No. Simulators are not part of your project. You can create new ones from Xcode's Devices and Simulators window, and unavailable ones can be removed safely.

Sources

  1. Apple Developer: Xcode documentation
  2. Apple Developer Forums: How to delete iOS simulator runtimes?
  3. Apple Developer Forums: Simulator runtime stuck Deleting