-
Notifications
You must be signed in to change notification settings - Fork 1
Clean Xcode Cache and DerivedData from Terminal
Xcode can accumulate gigabytes of generated files over time — including DerivedData, device support files, module caches, documentation caches, and build artifacts.
CleanMyMac CLI helps you find and review removable Xcode-related files directly from the Terminal before deciding what to delete.
Scan for Xcode-related junk:
cleanmymac clean junkCleanMyMac CLI scans supported locations and shows what it finds before anything is removed.
Review the detected items, select what you want to clean, and confirm the cleanup.
Nothing is removed until you review and confirm the selection.
Xcode creates several types of generated data during development.
Common examples include:
- DerivedData
- Device Support files
- Module Cache
- Documentation Cache
- Other generated Xcode-related files
These files can accumulate across projects and Xcode versions even when the original project is no longer active.
When you are not sure whether Xcode is responsible for your storage usage, start with:
cleanmymac analyzeOr inspect your Library directory:
cleanmymac analyze ~/LibraryUse the interactive storage explorer to navigate through large folders and understand what is consuming disk space.
Browsing with analyze does not modify your files.
Run:
cleanmymac clean junkThis category includes supported Xcode-related junk together with other system junk.
You can inspect the detected items before cleanup and deselect anything you want to keep.
Xcode-related generated files can also exist inside individual development projects.
Use:
cleanmymac purgeOr scan a specific development directory:
cleanmymac purge ~/Projectspurge looks for generated project artifacts and groups results by project.
Artifacts older than seven days are preselected. Newer artifacts remain visible but unchecked so you can review them manually.
cleanandpurgesolve different problems:
- Use
cleanmymac clean junkfor supported Xcode caches and generated data outside individual projects.- Use
cleanmymac purgefor removable build artifacts stored inside project directories.
If there is a project or directory you never want included in scan results, add it to the ignore list:
cleanmymac ignore add ~/Projects/important-projectReview ignored paths:
cleanmymac ignore listIgnored paths remain excluded until you remove them from the list.
When cleaning Xcode-related disk usage, a good workflow is:
cleanmymac analyzecleanmymac clean junkcleanmymac purgeInspect the paths and selection before confirming cleanup.
Avoid starting with --force when you have not reviewed what will be removed.
Analyze the relevant folders directly:
cleanmymac analyze ~/LibraryYou can also analyze a specific project directory:
cleanmymac analyze ~/ProjectsThis helps identify large files or directories that are not part of the supported cleanup categories.
CleanMyMac CLI requires macOS 11 or later and can be installed with Homebrew:
brew install --cask macpaw/taps/cleanmymac-cliThen run:
cleanmymac clean junk🩷 Built and used daily by the CleanMyMac team on our own Macs.