Is it safe to delete Xcode DerivedData on Mac?
Safe~/Library/Developer/Xcode/DerivedData
Yes. Xcode rebuilds DerivedData from your source files. What it holds, how to measure it, and how to clear it safely without touching your projects.
Verdict: Safe. You can delete ~/Library/Developer/Xcode/DerivedData at any time, because it only holds files Xcode generates from your projects and Xcode rebuilds them on the next build. Quit Xcode first, move the folder or its contents to the Bin, then empty the Bin to get the space back.
The only cost is time: the next build of each project starts from scratch, and Xcode has to index your code again.
What lives in DerivedData
Apple's Xcode locations help page describes derived data as "project indexes, logs, and build products including intermediate build files". Each project you build gets its own subfolder, named after the project followed by a string of random letters. Inside you will find:
- Index data, which powers code completion, jump to definition and search.
- Build products and intermediates, including compiled object files for every target and configuration you have built.
- Logs of builds and tests.
- Swift package checkouts that a project depends on.
Because every project you have ever opened leaves a folder here, DerivedData keeps growing long after you have finished with a project. Apple's same page notes that the folder is often large and can be re-created at any time from your source files.
What happens if you delete it
Everything in DerivedData rebuilds by itself:
- The next build compiles the whole project again instead of only what changed.
- Xcode re-indexes the project, so code completion may be slow or missing for a few minutes.
- Swift packages download again, so you need a network connection for the first build.
Nothing is lost for good. Your source code, project files, schemes, signing settings and Archives sit elsewhere. If you have changed the location in Xcode > Settings > Locations, the folder lives wherever you pointed it, so check there instead.
How to check its size safely
In Terminal, run:
du -sh ~/Library/Developer/Xcode/DerivedData
This prints the folder's total size. It only reads and changes nothing. To see which projects take the most room:
du -sh ~/Library/Developer/Xcode/DerivedData/* | sort -h
This lists each project's folder, smallest first, so the biggest end up at the bottom. If you have never installed Xcode, du reports that the folder does not exist.
In Finder:
- Choose Go > Go to Folder, paste
~/Library/Developer/Xcode/DerivedDataand press Return. - Choose View > as List, then View > Show View Options, and tick Calculate all sizes.
- Click the Size column to sort.
The safest way to get the space back
- Quit Xcode with Command-Q. Deleting these files while Xcode is running can confuse its indexer and build system.
- In Finder, choose Go > Go to Folder and open
~/Library/Developer/Xcode/DerivedData. - Select everything inside, or only the folders for projects you have finished with, and press Command-Delete to move them to the Bin.
- Open Xcode and build one project to check it works.
- Empty the Bin. As Apple's Free up storage space on Mac explains, the space only becomes available once you do.
From Terminal, macOS 14 Sonoma and later include a trash command:
trash ~/Library/Developer/Xcode/DerivedData
This moves the whole folder to the Bin, so you can still put it back. Xcode creates a fresh one on the next build. If you prefer to skip the Bin:
rm -rf ~/Library/Developer/Xcode/DerivedData
Warning: rm -rf deletes immediately and cannot be undone. Read the path twice before you press Return.
What never to touch
DerivedData is the easy part. The folders next to it need more thought:
- Archives in
~/Library/Developer/Xcode/Archiveshold the builds and debug symbols for every version you shipped. See is it safe to delete Xcode Archives before removing any. - Simulators in
~/Library/Developer/CoreSimulatorhold apps and test data. Remove them through Xcode orsimctl, as covered in is it safe to delete CoreSimulator. - Your project folders. A
buildfolder inside a project is sometimes configured by hand; check the project's settings before you delete it.
Our full guide to clearing Xcode DerivedData, simulators and archives covers all of these, and iOS DeviceSupport is often worth checking too.
How Headroom helps
Headroom's Clean scan looks for DerivedData and lists it under Developer caches as "Xcode build files", with its size and the note "Xcode rebuilds these on the next build." It is ticked by default, and clearing it deletes the folder for good rather than moving it to the Bin, because it rebuilds. Headroom does not check whether Xcode is open, so quit Xcode before you clean. The scan is free; the $19 one-time licence clears what you tick. See the cleaner or download Headroom.
Questions
Will deleting DerivedData delete my Xcode projects?
No. Your projects and source code live wherever you saved them. DerivedData only holds indexes, logs and build products that Xcode generates from those files, and it makes them again on the next build.
Why is my first build so slow after deleting DerivedData?
Xcode has to index the project and compile everything from scratch, and it fetches Swift package dependencies again. Later builds return to their usual speed.
Is Clean Build Folder the same as deleting DerivedData?
No. Product > Clean Build Folder clears build output for the project you have open. Deleting DerivedData clears indexes, logs and build products for every project you have ever built, so it frees much more space.
How often should I delete DerivedData?
Only when you need the space or when a build or index is behaving oddly. Clearing it on a schedule just makes your next builds slower.