Clean Rabbit

Guide

How to free up space on a developer's Mac

Developer tools are the quickest way to fill a Mac. Build products, simulators, container images and package caches all grow quietly, and almost all of it can be rebuilt. Here is where it hides and how to clear it safely.

Updated

1. See where the space went

du -sh ~/Library/Developer ~/Library/Caches ~/.npm ~/.gradle ~/.cargo ~/.docker 2>/dev/null | sort -h

Anything that does not exist is skipped. The biggest numbers tell you which section below to start with.

2. Xcode

WhatWhereSafe to clear?
Build products (DerivedData)~/Library/Developer/Xcode/DerivedDataYes. Quit Xcode first; the next build is slower while it rebuilds.
Device support files~/Library/Developer/Xcode/iOS DeviceSupportYes. Recreated when you next connect a device.
Archives~/Library/Developer/Xcode/ArchivesKeep the ones you may need for crash reports from shipped builds.
Simulators and runtimesManaged by XcodeUse the commands below.
xcrun simctl delete unavailable
xcrun simctl runtime list
xcrun simctl runtime delete <runtime-id>

The first removes simulators for runtimes you no longer have. The other two list simulator runtimes, which are several gigabytes each, and remove the ones you no longer test on.

3. Docker

docker system df
docker system prune

The first shows what Docker is using. The second removes stopped containers, unused networks, dangling images and build cache. Add -a to remove every image not used by a container.

Volumes hold data, such as local databases. They are only removed if you add --volumes, so leave that off unless you are sure.

4. node_modules

Every JavaScript project carries its own node_modules folder, often hundreds of megabytes each. To find them under a projects folder:

find ~/code -name node_modules -type d -prune -exec du -sh {} + | sort -h

Deleting one is safe; npm install brings it back. For an interactive list you can tick through, run npx npkill.

5. Package manager caches

ToolHow to clear
npmnpm cache clean --force
Homebrewbrew cleanup --prune=all
pippip cache purge
CocoaPodspod cache clean --all
GradleStop the daemons with ./gradlew --stop, then delete ~/.gradle/caches
CargoDelete ~/.cargo/registry/cache; crates download again when needed

6. Everything else

Many tools keep their caches in ~/Library/Caches, which Disk Cleaner covers with a review step. Point Large & Old Files at ~/Library/Developer or your projects folder to find virtual machine disks, old archives and forgotten build outputs, and use Duplicate Finder on asset folders.

Questions

Is it safe to delete DerivedData?

Yes. It only holds build products and indexes that Xcode recreates. Quit Xcode first, and expect the next build to take longer.

Will clearing caches slow me down?

Briefly. The next install or build downloads or rebuilds what it needs. The space you get back is usually worth it, especially on a nearly full drive.

What about System Data?

Developer tools are a common reason System Data is large. See what System Data on a Mac is.

Try Clean Rabbit

Free for Mac, Windows and Linux. ~10 MB, no card, no trial.