Skip to content

Clean Xcode Cache and DerivedData from Terminal

Nat edited this page Jul 20, 2026 · 1 revision

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.

Quick cleanup

Scan for Xcode-related junk:

cleanmymac clean junk

CleanMyMac 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.

What Xcode files can take up disk space?

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.

Check what is using space first

When you are not sure whether Xcode is responsible for your storage usage, start with:

cleanmymac analyze

Or inspect your Library directory:

cleanmymac analyze ~/Library

Use the interactive storage explorer to navigate through large folders and understand what is consuming disk space.

Browsing with analyze does not modify your files.

Clean Xcode caches and generated files

Run:

cleanmymac clean junk

This 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.

Clean build artifacts inside projects

Xcode-related generated files can also exist inside individual development projects.

Use:

cleanmymac purge

Or scan a specific development directory:

cleanmymac purge ~/Projects

purge 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.

clean and purge solve different problems:

  • Use cleanmymac clean junk for supported Xcode caches and generated data outside individual projects.
  • Use cleanmymac purge for removable build artifacts stored inside project directories.

Protect an active project

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-project

Review ignored paths:

cleanmymac ignore list

Ignored paths remain excluded until you remove them from the list.

A safe workflow

When cleaning Xcode-related disk usage, a good workflow is:

1. Understand what is taking space

cleanmymac analyze

2. Scan Xcode-related junk

cleanmymac clean junk

3. Check old project artifacts

cleanmymac purge

4. Review before deleting

Inspect the paths and selection before confirming cleanup.

Avoid starting with --force when you have not reviewed what will be removed.

What if Xcode is still taking a lot of space?

Analyze the relevant folders directly:

cleanmymac analyze ~/Library

You can also analyze a specific project directory:

cleanmymac analyze ~/Projects

This helps identify large files or directories that are not part of the supported cleanup categories.

Install CleanMyMac CLI

CleanMyMac CLI requires macOS 11 or later and can be installed with Homebrew:

brew install --cask macpaw/taps/cleanmymac-cli

Then run:

cleanmymac clean junk

🩷 Built and used daily by the CleanMyMac team on our own Macs.

Related guides

Learn more

Clone this wiki locally