Skip to content

Blog

What is DerivedData in Xcode, and how do you clean it?

What Xcode keeps in DerivedData, why it can fill up your Mac, and how to clean it safely, from Apple’s own Xcode Help.

· Sources

On this page

If you build apps in Xcode, one folder on your Mac can grow to many gigabytes without you noticing. It’s called DerivedData. This guide explains what it is, why it gets so large, and how to clean it, using Apple’s Xcode Help.

What is DerivedData?

DerivedData is where Xcode keeps the files it makes from your projects. Apple’s Xcode Help says derived data consists of:

  • project indexes
  • logs
  • build products, including intermediate build files

None of it is your project itself. Your source files stay in your project folder.

Source: Apple Xcode Help, Manage the locations of project-generated files in Xcode (opens in a new tab).

Where is the DerivedData folder on a Mac?

By default, Xcode keeps the derived data for all of your projects in one folder:

Folder
~/Library/Developer/Xcode/DerivedData

The ~ stands for your home folder. To open it:

  1. In the Finder, choose Go › Go to Folder.
  2. Type or paste ~/Library/Developer/Xcode/DerivedData, then press Return.

Inside, each project or workspace has its own subfolder. That’s Xcode’s default build location, which Apple calls Unique.

Source: Apple Xcode Help, Manage the locations of project-generated files in Xcode (opens in a new tab), and Apple Support, Go directly to a specific folder on Mac (opens in a new tab).

Why is my Mac filled with DerivedData?

Apple says the derived data folder is often large. Two things add up:

  • Xcode keeps it for all of your projects, not only the one you have open.
  • For each project, it keeps indexes, logs and build products, including the intermediate files made during a build.

So the more projects you build, the larger the folder gets.

Source: Apple Xcode Help, Manage the locations of project-generated files in Xcode (opens in a new tab).

Is it safe to delete DerivedData?

Yes. Apple’s Xcode Help says the derived data folder “can be re-created at any time from your source files.”

Deleting it doesn’t touch your code. Xcode makes what it needs again from your source files, so expect your next build of each project to take longer than usual.

Source: Apple Xcode Help, Manage the locations of project-generated files in Xcode (opens in a new tab).

How to clean DerivedData on your Mac

  1. Quit Xcode, so nothing is writing to the folder while you clean it.
  2. In the Finder, choose Go › Go to Folder, enter ~/Library/Developer/Xcode/DerivedData, then press Return.
  3. Select the subfolders you want to remove. To clean everything, choose Edit › Select All.
  4. Press Command-Delete, or drag them to the Trash in the Dock.
  5. Empty the Trash. The space only comes back once you do.

If you change your mind before emptying the Trash, open it, select the folders and choose File › Put Back.

Source: Apple Support, Delete files and folders on Mac (opens in a new tab) and Free up storage space on Mac (opens in a new tab).

How to clean DerivedData in Xcode

Apple’s Xcode Help doesn’t describe a command inside Xcode that deletes derived data, so this guide uses the Finder, as above.

What Xcode does let you choose is where derived data lives. In Xcode’s Locations settings, the Derived Data pop-up menu has three choices:

ChoiceWhere derived data goes
Default~/Library/Developer/Xcode/DerivedData
RelativeInside each project or workspace folder, for example /DerivedData
CustomAny folder you pick, with the folder icon in the path field

If you choose Relative, Apple suggests you don’t back up the folder, send it to others, or check it into a source control system such as Git.

Source: Apple Xcode Help, Manage the locations of project-generated files in Xcode (opens in a new tab).

Disk Census finds Xcode’s DerivedData, marks it safe to delete, and tells you the next build and indexing will take longer.

See how Disk Census works