How to clean up Xcode storage
Short answer: quit Xcode, then remove the simulator runtimes and platforms you no longer use in Xcode → Settings → Components, which shows how much space each one frees. Build data (DerivedData) and package caches are rebuilt or downloaded again when needed, so they cost time rather than work. Keep the archive of every build you've distributed; Apple says you need it to diagnose crash reports.
Xcode's data lives in several places, and each one costs something different to delete. The table gives the overview. The sections below explain each one, with Xcode's own tools first and then File Stacker.
| What | What it's for | What removing it does | Where to remove it |
|---|---|---|---|
| Simulator runtimes and platforms | The OS versions Simulator can run, and platform support | You can't use that runtime or platform until you download it again | Xcode: Settings → Components |
| DerivedData | Build intermediates and indexes | Xcode recreates them on the next build | File Stacker Cleanup: Xcode DerivedData |
| Simulator devices | Each simulator's disk, with the apps and data in it | Apps and data installed in those simulators are lost; Xcode recreates devices, empty, when needed | File Stacker Cleanup: Simulator Devices & Caches |
| Swift package caches | Cloned package repositories | Re-fetched on the next package resolve | File Stacker Cleanup: Swift Package Caches |
| CocoaPods, Gradle and Maven caches | Downloaded dependencies | Re-downloaded on the next build | File Stacker Cleanup: Gradle / Maven / CocoaPods Caches |
| Archives | Distributed builds with their debug symbols (dSYM files) | You may not be able to diagnose crash reports from those builds | Keep the ones you've distributed |
Before you start: quit Xcode and Simulator, so nothing is writing to these folders while you remove them.
Simulator runtimes and platforms
Simulator runtimes are the OS versions your simulators run, and platform support lets you build for a platform. They're usually the biggest Xcode items you can remove, and Xcode manages them itself.
- Choose Xcode → Settings and click Components. Xcode lists installed components with the storage you'd recover by removing each one.
- Under Platform Support or Other Installed Platforms, click the Info button next to a component you don't need.
- In the dialog, click Delete (or Turn Off for optional features).
Effect: you can't build for that platform or run that simulator runtime until you install it again. To get an older runtime back, click Add Platforms under Other Installed Platforms; Xcode downloads it again. File Stacker's Cleanup doesn't list runtimes, so manage them here.
DerivedData
File Stacker describes Xcode DerivedData as “build intermediates and indexes”. It's the output Xcode produces while it builds and indexes your projects, and Xcode's build system manages and cleans it.
- In File Stacker: open Cleanup, tick Xcode DerivedData and click Move Selected to Trash.
- In Xcode: a clean build removes a project's build output, so the next build starts from scratch.
Effect: Xcode recreates the data on the next build, so that build and indexing take longer than usual. Nothing in your source code or project settings changes.
Simulator devices
Each simulator has its own disk holding the apps you've installed in it and the data they've saved.
- In File Stacker: tick Simulator Devices & Caches in Cleanup. The app describes this category as every simulator's disk: you lose apps and data installed in simulators, and Xcode recreates devices, empty, when they're needed. Expand the row to see what it lists before you remove anything.
- In Xcode: in current Xcode, simulators appear in Device Hub (Xcode → Open Developer Tool → Device Hub). Control-click a simulator and choose Remove to take it off the list. Apple's documentation doesn't say whether this also deletes the simulator's data. Earlier Xcode releases manage simulators in a Devices and Simulators window instead.
- In Terminal: Apple points to
xcrun simctl helpfor simulator commands.
Effect: apps, accounts and test data inside the removed simulators are gone. Reinstall your app from Xcode to test again.
Swift package, CocoaPods, Gradle and Maven caches
Package managers keep downloaded dependencies so they don't have to fetch them for every build.
- In File Stacker: tick Swift Package Caches (“cloned package repositories, re-fetched on the next resolve”) or Gradle / Maven / CocoaPods Caches (“dependency caches, re-downloaded on the next build”).
Effect: the next package resolve or build downloads the dependencies again, so it needs a network connection and takes longer. Your project files aren't changed. The Gradle / Maven / CocoaPods category is a single row, so check its contents if you use those tools for other projects.
Archives
When you archive an app for distribution, Xcode stores its binaries and debug symbols (dSYM files) inside the archive. A crash report can only be matched to the dSYM from the exact same build.
Keep the archive of every build you've distributed. Apple's guidance is that without it you might not be able to diagnose issues from crash reports. Archives of test builds you never shipped are the ones to consider removing. File Stacker's Cleanup doesn't list archives.
Measure first with the treemap
File Stacker's treemap shows where Xcode's space is before you delete anything.
- Scan your Home folder. Granting it includes your Library folder.
- Drill into Library → Developer and select the largest blocks to see their size on disk.
- Right-click and choose Show in Finder to see where an item lives.
Don't delete the whole Developer folder. It holds more than caches, for example the component packages Xcode downloads and the folder Xcode uses to show connected devices' files. Remove the specific items above instead.
Restoring and getting the space back
- Everything File Stacker removes goes to the Trash. It never empties the Trash or deletes files permanently.
- To restore an item, select it in the Trash in Finder and choose File → Put Back, or use File Stacker's Recent Removals → Put Back. Both need the item to still be in the Trash.
- The space comes back only when you empty the Trash. Some of it fills up again as you work, because Xcode recreates build data and simulators.
- Runtimes and platforms removed in Xcode aren't restored from the Trash. Download them again in Settings → Components.
Sources
- Apple Developer: Downloading and installing additional Xcode components (Settings → Components, ~/Library/Developer/Packages)
- Apple Developer: Managing your simulated and physical devices in Device Hub
- Apple Developer: Interacting with devices using the command line (
xcrun simctl help, device mount point) - Apple Developer: Building your app to include debugging information (archives and dSYMs)
- Apple Developer: Creating build rules for custom file types (derived files and clean builds)
- Apple Support: Delete files and folders on Mac (Put Back, emptying the Trash)