How to clean up Xcode storage

By Little Mac Apps · Updated

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.

WhatWhat it's forWhat removing it doesWhere to remove it
Simulator runtimes and platformsThe OS versions Simulator can run, and platform supportYou can't use that runtime or platform until you download it againXcode: Settings → Components
DerivedDataBuild intermediates and indexesXcode recreates them on the next buildFile Stacker Cleanup: Xcode DerivedData
Simulator devicesEach simulator's disk, with the apps and data in itApps and data installed in those simulators are lost; Xcode recreates devices, empty, when neededFile Stacker Cleanup: Simulator Devices & Caches
Swift package cachesCloned package repositoriesRe-fetched on the next package resolveFile Stacker Cleanup: Swift Package Caches
CocoaPods, Gradle and Maven cachesDownloaded dependenciesRe-downloaded on the next buildFile Stacker Cleanup: Gradle / Maven / CocoaPods Caches
ArchivesDistributed builds with their debug symbols (dSYM files)You may not be able to diagnose crash reports from those buildsKeep the ones you've distributed

The File Stacker descriptions in this table are the ones the app shows in Cleanup.

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.

  1. Choose Xcode → Settings and click Components. Xcode lists installed components with the storage you'd recover by removing each one.
  2. Under Platform Support or Other Installed Platforms, click the Info button next to a component you don't need.
  3. 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.

These steps follow Apple's current Xcode documentation. Older Xcode releases may label this settings pane differently.

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.

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.

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.

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.

  1. Scan your Home folder. Granting it includes your Library folder.
  2. Drill into Library → Developer and select the largest blocks to see their size on disk.
  3. 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

Sources