Yes, Xcode DerivedData is safe to delete. It lives at ~/Library/Developer/Xcode/DerivedData and contains only build output, indexes and caches that Xcode regenerates the next time you open and build a project. Quit Xcode, then delete the folder's contents from Finder or with one Terminal command; your source code, schemes and signing settings are not stored there.
The rest of this guide explains what is inside the folder, why it grows, three ways to clear it, and the neighbouring folder you should not treat the same way.
What DerivedData actually contains
When you open a project or workspace, Xcode creates a subfolder in DerivedData named after the project plus a long hash, for example MyApp-abcdefghijklmnop. Inside it you will typically find:
- Build: the compiled products and intermediate object files for each scheme, configuration and destination.
- Index.noindex: the index that powers code completion, jump to definition and find in project.
- Logs: build, test and debug session logs you see in the Report navigator.
- SourcePackages: checked-out Swift packages and their resolved versions for that project.
Alongside the per-project folders there is usually a shared ModuleCache.noindex, which holds precompiled Clang and Swift modules reused across projects.
None of this is something you wrote. It is all derived from your sources, which is where the name comes from.
Why it grows so large
Xcode never cleans up DerivedData for projects you stop opening. Every branch switch that changes build settings, every new simulator or device destination, every Xcode upgrade and every renamed project can leave another set of build products behind. If you clone the same repository into two places, you get two folders. Over months it can reach many gigabytes, and it is often one of the largest folders in ~/Library/Developer.
Check yours before deciding:
du -sh ~/Library/Developer/Xcode/DerivedData
# Size of each project folder, largest last
du -sh ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null | sort -h
The second command is useful if you only want to remove projects you have abandoned and keep warm builds for the one you are working on today.
Before you delete: quit Xcode
Deleting DerivedData while Xcode has the project open can leave the indexer and build system confused, and Xcode may immediately start writing new files into the folder you are deleting. Quit Xcode (Command-Q), and also quit Simulator if a debug session is running. If you use a command-line build loop with xcodebuild, stop it as well.
Method 1: from Xcode's settings
This is the easiest way to find the right folder, especially if you or your team changed its location.
- Open Xcode and choose Xcode › Settings.
- Click the Locations tab.
- Next to Derived Data, click the small arrow at the end of the path. Finder opens with the folder selected.
- Quit Xcode.
- In Finder, open the DerivedData folder, select everything inside (Command-A), and choose File › Move to Trash.
- Empty the Trash when you are sure you want the space back.
The Derived Data pop-up in the same pane also tells you whether the location is the default or a custom or relative one. A relative setting puts DerivedData inside each project folder instead, which matters if you are looking in the wrong place and finding nothing.
Method 2: Finder with Go to Folder
If you just want the default location:
- In Finder, press Shift-Command-G (Go › Go to Folder).
- Paste
~/Library/Developer/Xcode/DerivedDataand press Return. - Select the project folders you want to remove, or all of them, and choose File › Move to Trash.
Moving to Trash rather than deleting outright gives you a way back if you remove something by mistake, though for DerivedData there is very little to regret.
Method 3: Terminal
This is the quickest way, and it is the one most developers end up scripting. It deletes immediately and does not use the Trash, so check the path carefully before pressing Return.
# Quit Xcode first, then:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
To clear a single project's derived data instead, delete only its folder:
rm -rf ~/Library/Developer/Xcode/DerivedData/MyApp-*
If your team uses a custom location, find it with:
defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null
No output means the default path is in use.
Clean Build Folder is not the same thing
Product › Clean Build Folder (Shift-Command-K) removes the build products of the project that is open right now. It leaves that project's index in place and does not touch the folders of any other project. Use it when a single build behaves oddly. Use the methods above when you want disk space back across everything you have ever built.
What happens after you delete it
The next time you open a project, Xcode re-indexes it. Code completion and jump to definition may be slow or incomplete for a few minutes while the progress indicator in the toolbar runs. The first build is a full build, not an incremental one, so it takes longer than usual. Swift packages are fetched again, which needs a network connection. After that, things are back to normal.
Clearing DerivedData is also a common fix for stale indexes, phantom build errors that refer to files you already deleted, and SwiftUI previews that refuse to update. If you are troubleshooting rather than freeing space, that is a reasonable first step.
Do not delete Archives the same way
One folder over, ~/Library/Developer/Xcode/Archives looks similar but is not a cache. Every archive you made for TestFlight or the App Store is kept there, together with its dSYM files. Without those dSYMs you cannot symbolicate crash reports from that build. Manage archives in Window › Organizer › Archives, and only delete versions that are no longer in anyone's hands.
While you are in ~/Library/Developer, two other folders often grow next to DerivedData: symbols for every OS version you have connected (see deleting old iOS DeviceSupport folders) and leftover simulators (see deleting old Xcode simulators and runtimes).
How CleanLoupe does it
CleanLoupe's developer cleanup lists Xcode DerivedData as its own item in the Cleanup module, labelled Safe, with its size. Selecting it and clicking Clean moves the contents to the Trash and records them in History, where Put Back restores them until you empty the Trash. Files written in the last hour are not preselected, so an in-progress build does not get swept up.
It shows the related Xcode folders next to it: simulator caches, SwiftUI preview data, device logs and the documentation cache are also Safe. Xcode Archives appear as Careful and are never preselected, for the dSYM reason above.
What it does not do: it does not read Xcode's custom DerivedData location setting, so if you moved DerivedData inside your projects, use Method 3 with that path. It also does not quit Xcode for you, so do that first. CleanLoupe is free, with no subscription or account.
If you would rather use a single-purpose tool, DevCleaner for Xcode is an open-source app focused on Xcode folders and is a good option too.
For the wider picture of developer caches, from Gradle to Go, see freeing up disk space on a developer Mac.
FAQ
Where is Xcode DerivedData located?
By default it is at ~/Library/Developer/Xcode/DerivedData in your home folder. The quickest way to confirm is Xcode › Settings › Locations, where the arrow next to Derived Data opens it in Finder. If the setting is Relative, each project keeps its own DerivedData inside the project folder.
Does deleting DerivedData delete my code?
No. DerivedData contains only build products, indexes, logs and package checkouts that Xcode generates from your project. Your source files, project settings, schemes and signing configuration live in the project folder, not in DerivedData.
How often should I clear Xcode DerivedData?
There is no schedule you need to follow. Clear it when disk space is short, when you have stopped working on several projects, or when Xcode shows build or index errors that do not make sense. Clearing it too often just means more full builds.
How do I clear the Xcode cache?
What people call the Xcode cache is mostly DerivedData, plus Xcode's own cache folder at ~/Library/Caches/com.apple.dt.Xcode. Quit Xcode, then delete both. Xcode rebuilds them on the next launch and build, so the first build afterwards is slower.
Is it safe to delete DerivedData while Xcode is open?
It is better not to. Xcode may be writing to the folder, and the indexer can end up in an odd state until you restart. Quit Xcode, delete the folder's contents, then reopen your project.
When you want the folder cleared without typing paths, download CleanLoupe and look for DerivedData at the top of Cleanup's Developer group.