Disk hygiene on a build Mac: DerivedData, simulators, caches and snapshots
A build Mac rarely fills its disk in one step; build products, simulator runtimes and caches accumulate quietly. This checklist shows how to measure each source, what is safe to remove, and how to automate cleanup and alerts.

Disk pressure on a CI or build Mac can surface as a confusing failure: a link step that cannot write or an archive that stops halfway. Often the cause is gradual accumulation rather than a single large file. This checklist covers where the space goes, how to measure it, what is safe to remove and how to automate the routine.
Measure before you delete
Start with the volume, then drill down: df reports free space and du sizes directories.
df -h /
du -sh ~/Library/Developer/* 2>/dev/null | sort -h
du -sh ~/Library/Caches/* 2>/dev/null | sort -h | tail -15
The first command shows whether there is a problem; the next two rank the usual suspects in your home folder. Simulator runtimes are stored outside it, so list them with xcrun simctl runtime list, and Xcode's Components settings show how much storage removing each component would recover.
Where the space usually goes
| Item | Common location | Rebuildable? |
|---|---|---|
| DerivedData | ~/Library/Developer/Xcode/DerivedData | Yes |
| Archives | ~/Library/Developer/Xcode/Archives | Keep those of distributed builds |
| Simulator devices | ~/Library/Developer/CoreSimulator/Devices | Yes, but app data is lost |
| Simulator runtimes | System locations outside your home folder | Re-downloadable |
| SwiftPM cache | ~/Library/Caches/org.swift.swiftpm | Yes |
| CocoaPods cache | ~/Library/Caches/CocoaPods | Yes |
| Homebrew downloads | Shown by brew --cache | Yes |
Apple's Xcode Help documents the default DerivedData and Archives locations; the other rows reflect common practice and may differ by Xcode release, so check them before scripting deletions.
What is safe to remove, and what to keep
Apple's Xcode Help describes derived data as project indexes, logs and build products, intermediate files included, and says the folder can be re-created from your source files. Deleting it costs a full rebuild and re-indexing and also removes those logs and products, so first copy any you still need. Close Xcode and stop builds before removing it.
Apple's Xcode documentation says an archive holds your app's binaries with their dSYM files, and that you must keep the archive of every build you distribute, or you may be unable to diagnose issues from crash reports. Move those archives to long-term storage; only archives that were never distributed are candidates for cleanup.
Package caches (SwiftPM, CocoaPods) can be downloaded again. The Homebrew manual says brew cleanup deletes stale lock files and outdated downloads, removes old versions of installed formulae and, by default, drops downloads older than 120 days, so preview it first:
brew cleanup --dry-run
brew cleanup
If Docker is installed, review docker system df (see Docker's reference) before pruning, because images and volumes may belong to other jobs.
Simulators: use the tools, not rm
Runtimes and devices are tracked by CoreSimulator, so manage them with simctl rather than by deleting folders. Users in one Developer Forums thread report that rm fails on runtime files under /System/Library/AssetsV2, which System Integrity Protection guards. Check xcrun simctl help and xcrun simctl help delete on your machine before scripting, including how it decides which devices count as unavailable when several Xcode versions are installed.
xcrun simctl list runtimes
xcrun simctl runtime list
xcrun simctl delete unavailable
The last command deletes devices that are no longer available, such as those whose runtime is gone, together with their data; an Apple engineer suggests it in a forum answer. It does not remove runtime images. Runtimes have their own subcommand, usually xcrun simctl runtime delete with an identifier from the list output; syntax may vary by Xcode version. Simulators that rely on a removed runtime become unavailable until it is downloaded again, so confirm no pipeline needs it.
In current Xcode, Apple's documentation points to Xcode > Settings > Components: runtimes appear under Other Installed Platforms and are removed with the information button, then Delete. Older releases may label this screen differently.
Time Machine local snapshots
When Time Machine backs up automatically, it keeps local snapshots on the startup disk: one roughly every hour, each kept for 24 hours, plus one of the last successful backup until space is needed. Apple says the space they occupy counts as available storage and that they are deleted as they age or as space is needed. To clear them, Apple suggests switching Time Machine to manual backups for a few minutes, then turning automatic backups back on. The tmutil tool lists and thins them.
tmutil listlocalsnapshots /
tmutil listlocalsnapshotdates
According to the SS64 reference, tmutil thinlocalsnapshots takes a mount point, an optional purge amount in bytes and an urgency from 1 to 4; SS64 is third-party, so check man tmutil locally.
Schedule the cleanup with launchd
Apple's Terminal User Guide lists ~/Library/LaunchAgents for agents of the logged-in user only and /Library/LaunchDaemons for system daemons. Apple's archived launchd guide explains that StartCalendarInterval runs a job at a calendar time, with omitted keys acting as wildcards. Pick an hour when no builds run.
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key><integer>3</integer>
<key>Minute</key><integer>30</integer>
</dict>
Point the job at a script that removes DerivedData entries older than a set number of days, runs brew cleanup and xcrun simctl delete unavailable, and logs what it did. Install it as an agent in the build user's ~/Library/LaunchAgents, because the cleanup targets live in that user's home folder. The archived guide says a user agent runs only while its user is logged in, so keep that account logged in.
Add a free-space alarm
Cleanup is not monitoring. A small second script can warn before builds fail.
FREE_GIB=$(df -g / | awk 'NR==2 {print $4}')
if [ "$FREE_GIB" -lt 40 ]; then echo "low disk: ${FREE_GIB} GiB free" | logger -t diskwatch; fi
Run it once by hand, compare the number with the Avail column of df -h /, then route the message to your usual alerts. The 40 GiB figure is a placeholder (df -g counts 1 GiB blocks, per Apple's df manual source); base the threshold on the largest archive or build your pipeline produces.
Sources
- Apple Xcode Help: Manage the locations of project-generated files in Xcode
- Apple Developer Documentation: Building your app to include debugging information
- Apple Developer Documentation: Downloading and installing additional Xcode components
- Apple Support: About Time Machine local snapshots
- Apple Mac User Guide: About Time Machine local snapshots on Mac
- Homebrew Documentation: Manpage (brew cleanup, brew --cache)
- Docker Docs: docker system df
- Apple Developer Forums: How to clean Xcode build files? (DTS Engineer answer)
- Apple Developer Forums: Orphaned simulator runtime in /System/Library/AssetsV2 (user reports)
- SS64: tmutil reference (third-party)
- Apple Terminal User Guide: Script management with launchd in Terminal on Mac
- Apple Documentation Archive: Creating Launch Daemons and Agents
- Apple open source (file_cmds): df(1) manual page source


