Is It Safe to Delete Xcode DerivedData? Yes, and Here Is the Cost
DerivedData is often the largest folder a developer has never opened. It is safe to delete, and Xcode recreates it, but the next build of every project will be a full one. Here is what it holds and how to clear it properly.
Yes, it is safe. DerivedData contains only things Xcode generated from your projects: build products, indexes and caches. Your source code, project settings and signing certificates are stored elsewhere. The cost is time: the next build of each project starts from nothing, and Xcode re-indexes the code.
What DerivedData contains
The folder lives at ~/Library/Developer/Xcode/DerivedData. Inside is one subfolder per project or workspace, plus shared caches. Each holds:
- Build products and intermediates: the compiled app and the object files used for incremental builds.
- The index: what powers code completion, jump to definition and refactoring.
- Module and package caches: precompiled modules and Swift package build output.
- Logs: build and test logs shown in the Report navigator.
Because Xcode never cleans this folder on its own, it keeps data for projects you stopped working on years ago. Tens of gigabytes is common.
How to delete it
- Quit Xcode, so it is not writing to the folder.
- In Finder choose Go → Go to Folder… and enter
~/Library/Developer/Xcode/DerivedData. You can also open it from Xcode → Settings → Locations, using the arrow beside the Derived Data path. - Move the contents to the Trash. To clear a single project, move only its subfolder.
- Open Xcode and build. The folder is recreated.
For one project, Product → Clean Build Folder (Shift-Command-K) inside Xcode removes that project’s build products without touching the others.
What it costs you
The first build of each project afterwards is a clean build, which on a large app can take many minutes. Swift packages are resolved and built again, which may need a network connection. Code completion is limited until indexing finishes. Old build and test logs are gone. Nothing else changes.
So clear it when you need the space or when Xcode is behaving strangely, not as a daily habit.
Other Xcode folders that take space
- iOS DeviceSupport (
~/Library/Developer/Xcode/iOS DeviceSupport): debug symbols for each iOS version you have connected. Safe to remove; Xcode recreates the one it needs the next time you connect a device. - Simulators (
~/Library/Developer/CoreSimulator): simulator devices and their data. Remove old runtimes in Xcode’s Settings under Components (called Platforms in some versions), as Apple describes. Deleting a simulator device deletes the app data inside it. - Archives (
~/Library/Developer/Xcode/Archives): keep these for any version you have shipped. They hold the debug symbols needed to read crash reports for that build, and Xcode cannot recreate them.
The same idea for other developer caches
Most build tools keep a similar cache that is safe to remove at the cost of a slower next run: Gradle, CocoaPods, Cargo, pip and npm among them. Before clearing any of them, check which ones are actually big: see how to find large files and folders on a Mac.
See how big each Xcode folder is
Before clearing anything, find out where the space actually is. This read-only command lists the size of each folder Xcode uses:
du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator ~/Library/Caches/org.swift.swiftpm 2>/dev/null
DerivedData is often the largest, but on Macs used for iOS work, simulators and device support files can be bigger still.
Clear it from Terminal
With Xcode quit, these commands do the same as the Finder steps above. They delete immediately rather than moving items to the Trash, so check each path before pressing Return:
rm -rf ~/Library/Developer/Xcode/DerivedData/*empties DerivedData.xcrun simctl delete unavailableremoves simulator devices that your installed Xcode no longer supports. Simulators you can still run are left alone.rm -rf ~/Library/Caches/org.swift.swiftpmclears the Swift Package Manager cache. Packages are downloaded again on the next resolve.
Leave ~/Library/Developer/Xcode/Archives out of any clean-up script; it cannot be recreated.
Quick answers
Will deleting DerivedData delete my project or source code?
No. Your code lives wherever you saved the project. DerivedData holds only files Xcode generated from it.
Does deleting DerivedData fix Xcode problems?
Often. Stale build products and a damaged index cause errors that make no sense, and clearing the folder forces Xcode to rebuild both.
How often should I clear it?
When you need the space or Xcode misbehaves. Clearing it regularly only makes your builds slower.
Working in JavaScript as well? See how to clear the npm cache and old node_modules folders.