~/t/g/mac $

Xcode DerivedData filling your Mac? Remove unused caches

gist Find the actual DerivedData location, move only the selected project cache to Trash, then rebuild and check before deleting it permanently.

contents
  1. Step 1: Find the actual DerivedData location
  2. Step 2: Remove only the affected project cache
  3. Step 3: Rebuild and check before emptying Trash
  4. Step 4: Keep cache growth within a budget
  5. Compare the cleanup options
  6. Common questions

If Xcode DerivedData is filling your Mac, remove only an identified project cache after stopping builds. Xcode regenerates its build outputs, intermediates and indexes, so expect a slower next build.

I use a Mac mini as the build/test box, so this is the cleanup I run when it gets tight. Keep source, archives, device support, simulators and Keychain data separate.

Step 1: Find the actual DerivedData location

Open Xcode > Settings > Locations. Find the Derived Data row and use its arrow to open the location in Finder. A custom path can differ from the usual folder under your home directory. Check project or workspace settings too if the expected cache is missing.

Check the folder’s total size at the usual location:

du -sh "$HOME/Library/Developer/Xcode/DerivedData"

# Example output, with the home path abbreviated:
# 18G    ~/Library/Developer/Xcode/DerivedData

If Xcode uses a custom location, substitute that confirmed path. A missing folder at the default path does not mean there is nothing to clean.

Identify the affected project’s folder before moving anything. Confirm its connection to the project or workspace. If the name is ambiguous, leave it alone. Generated products and intermediates have their own configurable paths, as described in Apple’s build settings reference.

For a build problem, try Product > Clean Build Folder first, then build again. This clears build files so Xcode can rebuild them. It does not remove every kind of DerivedData. Apple’s build and run instructions

Step 2: Remove only the affected project cache

Before moving the folder:

  1. Stop the current build or test run.
  2. Pause queued build jobs, including jobs started over SSH.
  3. Quit Xcode.
  4. Confirm that no build job is still using the selected cache.

Move only the identified project DerivedData folder to Trash in Finder. Keep it there while you check the next build. Preserve any generated build outputs you still need.

Do not delete the whole Library/Developer folder. Do not sweep unrelated caches, archives or simulator data into the same cleanup.

Apple’s team cautions against treating repeated DerivedData deletion as normal build maintenance: recurring failures deserve investigation. Apple’s Xcode tips and tricks lab

Diagram: delete the affected project cache after stopping builds; keep source, archives and signing data.
Only the one project cache goes to Trash. Source, archives and signing data stay where they are, and the next build regenerates what was removed.

Step 3: Rebuild and check before emptying Trash

Reopen the project or workspace. Build the target you need, then run its usual tests or launch check.

Allow time for regenerated build files and indexes. If the removed folder included package checkouts or artifacts, Xcode may need to fetch dependencies again. Make sure those dependencies are available before cleanup on an offline build Mac.

Moving files to Trash does not free their storage yet. Keep enough spare room for the check build. If the disk is already full, first free space elsewhere or preserve the selected cache on another volume before removing the local copy. Apple’s storage guidance

Once the build and checks pass, review the selected folder in Trash. To remove just that folder permanently, Control-click it and choose Delete Immediately. Review all other Trash contents before choosing Empty Trash. Before permanent deletion, Finder also offers File > Put Back for items you need to recover. Apple’s file deletion instructions

Step 4: Keep cache growth within a budget

Choose a cache budget and a minimum free-space threshold that suit your builds. Leave room for the next build, tests and tool updates.

Set a cache policy:

  • Keep caches for active projects.
  • Review caches for retired projects or workspaces.
  • Perform cleanup between jobs while holding the build lock.
  • Check free space before starting a large build.
  • Record what was removed and whether the next build passed.

Avoid deleting every cache before every build. It adds rebuild work and can hide the cause of a recurring failure.

Compare the cleanup options

Option Best use Tradeoff
Clean Build Folder First check for stale build outputs Does not remove all DerivedData
Selected project folder to Trash Removing one known project cache Requires careful identification and room for a check build
Bounded cache policy Keeping a shared build Mac usable Needs job coordination and regular review

Common questions

Is it safe to delete Xcode DerivedData?

Yes, for an identified folder containing generated project data, after stopping builds. Xcode regenerates that data. Preserve any build outputs you still need, and expect a slower next build.

Does deleting DerivedData delete my source code?

Deleting the correct generated-data folder leaves your project source in place. Confirm the location first, especially with custom build paths. Keep the source folder out of the cleanup.

Does deleting DerivedData remove archives or simulators?

Archives, simulator data and device support are separate from the selected project cache. Manage them through their own controls. Do not delete their parent folders as a shortcut.

Why is disk space still low after moving DerivedData to Trash?

The files still occupy storage until deleted permanently. A new build also creates fresh cache data. Check both Trash and the active DerivedData location.

Should I delete DerivedData every day?

Usually no. Keep active caches and remove known unused ones when space requires it. If deletion repeatedly fixes the same build error, investigate that error rather than relying on daily cleanup.

Can I move DerivedData to another drive?

Yes. Xcode supports a custom Derived Data location in Settings > Locations. Confirm that the drive is mounted and writable before builds, and check any separate paths used by headless jobs. Moving the cache changes where it grows; it does not limit its size. If the drive drops off during sleep, see external SSD disconnects when your Mac sleeps.

Related: Mac guides · guide index.

../mac/ every Mac guide