Where Xcode Stores DerivedData

Updated · MintDisk team

MintDisk Developer Pack listing Xcode simulators and other developer data that can be removed

DerivedData is where Xcode keeps build products, intermediate files, indexes and logs for every project you open. It is what makes the second build fast, and it can grow to tens of gigabytes on a Mac that has seen many projects. This guide explains the Xcode DerivedData location, how to confirm it on your Mac, and how to clear it without losing anything you need.

It also covers the other Xcode folders that grow over time, simulators, runtimes, archives and device support files, and which of them you should keep. All steps assume Xcode is installed in the usual way from the App Store or Apple's developer site.

The default DerivedData location

By default, Xcode stores DerivedData in your home folder:

~/Library/Developer/Xcode/DerivedData
Finder showing the DerivedData folder in Library, Developer, Xcode, with one folder per project and its size
DerivedData holds one folder per project, named after the project plus a random suffix. Example output with demo files.

Inside, each project has its own folder whose name starts with the project name. It contains that project's build products, index, logs and other intermediate files.

Because ~/Library is hidden in Finder, open the folder with Go > Go to Folder (Shift-Command-G) and paste the path above, or run open ~/Library/Developer/Xcode/DerivedData in Terminal.

Check the location in Xcode's settings

The location can be changed, so check what your Xcode uses before you look for the folder.

  1. Open Xcode and choose Xcode > Settings (Xcode > Preferences in older versions).
  2. Click Locations.
  3. Under Derived Data, you see the current setting: Default, Relative to the workspace, or a Custom folder. Click the small arrow next to the path to open it in Finder.

If the setting is Relative, each workspace keeps its DerivedData next to the project. Look for a DerivedData folder in your project folders instead.

Why DerivedData grows so large

Xcode creates a DerivedData folder for every project and workspace you open, and keeps it after you close the project or delete it from disk. Each folder holds build products for every configuration and destination you built, such as Debug and Release for a simulator and a device, plus the index Xcode uses for search and code completion. Large projects with many dependencies, and projects built for several platforms, produce the largest folders.

Nothing removes these folders automatically. A Mac used for iOS development for a few years can easily hold dozens of them for projects that no longer exist.

See how big it is

This Terminal command only reads and lists each project's DerivedData folder by size, largest last:

du -sh ~/Library/Developer/Xcode/DerivedData/* | sort -h
Terminal running du -sh on each DerivedData folder, sorted from smallest to largest
The largest project folders end up at the bottom. Example output with demo files.

Folders of projects you deleted or no longer open are the first candidates for removal.

Clean up DerivedData

Everything in DerivedData can be regenerated by Xcode. It holds no source code, no project settings and no signing certificates. The cost of deleting it is time: the next build is a full build, and Xcode re-indexes the project before code completion and search work fully.

One project: Clean Build Folder

With the project open, choose Product > Clean Build Folder (Shift-Command-K). It removes the build products and intermediate files Xcode created for that project.

One project: delete its folder

  1. Quit Xcode.
  2. Open ~/Library/Developer/Xcode/DerivedData in Finder.
  3. Move the folder whose name starts with the project's name to the Trash.

All projects

Quit Xcode first. The command below deletes the folder's contents permanently, without the Trash. Check the path twice before you press Return.

rm -rf ~/Library/Developer/Xcode/DerivedData/*

Xcode recreates the folders as soon as you open and build a project again.

Remove only old project folders

Rather than clearing everything, remove the DerivedData of projects you have not built for a month. First list them; this only reads:

find ~/Library/Developer/Xcode/DerivedData -mindepth 1 -maxdepth 1 -type d -mtime +30

-mtime +30 matches folders not modified in the last 30 days. Check the list, then quit Xcode and delete those folders in Finder, or add -exec rm -rf {} + to the same command to delete them permanently.

With -exec rm -rf, the folders are removed at once, without the Trash. Run the listing first and make sure the path starts with ~/Library/Developer/Xcode/DerivedData.

Other Xcode data that takes space

DerivedData is often not the only large Xcode folder. Handle these differently:

WhatWhere to manage itSafe to remove?
Simulator runtimes and platformsXcode > Settings > Components, Info button > DeleteYes, for platforms you don't target; Xcode can download them again
Simulators whose runtime is gonexcrun simctl delete unavailableYes; Apple describes it as deleting devices that are no longer available
ArchivesWindow > Organizer > ArchivesKeep archives of builds you distributed
Device support filesCreated by Xcode when you connect a device for debuggingOld versions for devices you no longer use

Apple asks developers to keep the Xcode archive of every build they distribute. Without it, including its dSYM files, you might not be able to diagnose crash reports from that version. Delete only archives of builds you never shipped.

In the Components settings, Xcode shows each installed platform and how much storage you can recover by removing it. This is the supported way to remove simulator runtimes.

List and remove simulators

Simulator devices keep their own data, such as installed apps and settings. To see every simulator device Xcode knows about, this command only reads:

xcrun simctl list devices

Devices marked as unavailable belong to a runtime that is no longer installed. Remove all of them at once:

xcrun simctl delete unavailable

To remove a whole simulator runtime, such as an old iOS version, use Xcode > Settings > Components rather than deleting files: Xcode shows how much storage each component takes and removes it cleanly.

Should you move DerivedData?

You can point Derived Data to a Custom location, such as a fast external SSD, in Xcode > Settings > Locations. It frees internal storage, but builds then depend on the external drive being connected, and a slow drive makes builds slower. For most people, clearing old project folders now and then is simpler.

Questions and answers

Will deleting DerivedData delete my code?

No. Your source files, project files and assets live in the project folder, not in DerivedData. Only build products, indexes and logs are removed.

Does clearing DerivedData fix build errors?

Sometimes. Stale build products or a damaged index can cause strange errors, and a clean build rules them out. Try Product > Clean Build Folder first; delete the project's DerivedData folder if the problem persists.

How often should I clear it?

Only when you need the space or are troubleshooting. Removing folders of projects you no longer open is the most useful habit; clearing the folder of the project you work on every day only costs build time.

Can I keep DerivedData out of my Time Machine backups?

Yes. In Time Machine settings, open the options and add ~/Library/Developer/Xcode/DerivedData to the list of excluded items. Because Xcode can always rebuild it, backing it up mostly costs space on the backup disk.

Is DerivedData shared between Xcode versions?

With the default setting, every installed Xcode uses the same DerivedData folder. If you keep a beta next to the release version, both add to it, so clearing old project folders helps even more on a Mac with several Xcode versions.

Clean Xcode data with a plan you review

MintDisk's Deep cleanup measures Xcode DerivedData, documentation caches and old device logs, simulator caches and DeviceSupport folders, marks them Check first and selects none of them for you. Archives are shown for review only and are never cleaned. Developer Pack can also remove simulators whose runtime is no longer installed. Xcode must be closed, and cleaned Xcode data is deleted permanently.

MintDisk Developer Pack listing local AI models, unused Docker images, stopped containers and unavailable Xcode simulators
MintDisk's Developer Pack: Docker leftovers and unavailable Xcode simulators, each with its size.

Related

Sources

First published . Commands and menu paths were checked against the sources above on the update date.

Ask AI assistants about MintDisk

Independent, real-time insights from major language models.