Part of: Mac disk cleanup for developers: every cache, what it costs to rebuild (Developers)
Xcode is one of the largest sources of regenerable data on a developer’s Mac. Most of it sits under one folder, ~/Library/Developer, and most of it can be recreated. The difference between the folders is what recreating costs you.
Quit Xcode and any running simulators before removing anything. To see what is large before you decide, run this in Terminal:
du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator
On a Mac where Xcode has never been used for device debugging, you will not see every folder below. That is normal.
Safe, risky, never
- Safe:
DerivedData, oldiOS DeviceSupportentries. Cost: a rebuild, or a symbol copy when you reconnect a device. - Risky: simulated devices that hold app data you want, runtimes you still test on. Cost: lost test data, or a large download.
- Never:
Archives, unless you are sure you will not need crash reports from that build.
DerivedData
DerivedData is where Xcode puts the files it makes while building: compiled code, indexes and intermediate files. The path is ~/Library/Developer/Xcode/DerivedData. It has one subfolder per project you have opened.
This is the safest folder to clear, because Xcode rebuilds it. The cost is time. The next build of each project starts from scratch, and the index that powers code completion is built again. Expect the first build and the first minutes of code completion to be slow.
You do not have to clear all of it. Delete only the subfolder of a project you have finished with, and keep the ones you use every day. Check which folders are large with du -sh ~/Library/Developer/Xcode/DerivedData/* | sort -h.
If a project behaves strangely after an Xcode update, clearing its subfolder is a common first step, so this can fix stale build state as well as free space.
iOS DeviceSupport
~/Library/Developer/Xcode/iOS DeviceSupport holds debug symbols that Xcode copies from a physical iPhone or iPad the first time you connect it on a given system version. Debug symbols are what let Xcode show readable names while you debug.
Old entries for system versions you no longer use are dead weight. Xcode copies the symbols again when you next connect a device on that version. That takes a few minutes, so removal is safe but not free. Folders for other platforms, such as watchOS, work the same way.
Simulators
A simulator is a pretend iPhone or iPad that runs on your Mac. Its data lives in ~/Library/Developer/CoreSimulator. Two things take space:
- Runtimes. A runtime is the simulated operating system, such as an iOS version. Each one is several gigabytes. List the ones installed with
xcrun simctl runtime list. Remove runtimes you no longer need from Xcode’s own settings, not by deleting folders by hand. - Devices. Each simulated device stores its own apps and data. List them with
xcrun simctl list devices. Removing a device removes the apps and data inside it, so keep any simulator that holds test data you want.
The CoreSimulator guide goes deeper on these two.
Archives: keep these
~/Library/Developer/Xcode/Archives looks like more build output, but it is not disposable. Archives are what you ship, and they contain the symbols that make crash reports from released versions readable. Delete an archive only when you are certain you will never need to read crashes from that build.
What the next build costs
- After clearing DerivedData: a full rebuild of each project.
- After clearing DeviceSupport: a symbol copy when you reconnect a device.
- After removing a runtime: a download if you need it again.
None of this is data loss, but on a slow connection or a large project it is real time. The full folder-by-folder view is in Is it safe to delete ~/Library/Developer?, and the wider map is in the developer cleanup guide.
Worked example: pick one project
Say one old project is eating space. List the DerivedData subfolders from the newest to the oldest:
ls -t ~/Library/Developer/Xcode/DerivedData
On the Mac used to check this article, the list held a few folders per project, plus shared folders such as ModuleCache.noindex and SDKStatCaches.noindex. A project folder name is the project name, a dash and a hash. The shared folders are caches that Xcode shares between projects. Clearing them is also safe, but the next build of every project becomes slower, so leave them if you build daily.
The order is: find the project you finished, quit Xcode, move only that subfolder to the Trash, and empty the Trash. Nothing else needs to change.
Check what your runtimes are
This command prints which simulator runtimes Xcode knows:
xcrun simctl list runtimes
On that Mac it listed two iOS runtimes. If you only test on one of them, the other is the big saving, because each runtime is several gigabytes. Remove it in Xcode’s settings.
If something goes wrong
- Xcode says it cannot find a build product. Build the project again. DerivedData is recreated by the build.
- Code completion is empty or slow. The index is being rebuilt. Wait a few minutes and keep Xcode open.
- A device you plug in is slow to prepare. Xcode is copying the symbols again, which is the cost of clearing DeviceSupport.
- A simulator you need is gone. Add the runtime again in Xcode. Apps you installed in the removed device are not recovered.
When not to clean
Do not clear DerivedData in the middle of debugging an odd build problem unless you mean to. A clean build takes a while, and if you clear it every day you lose the speed it was made to give. Do it once in a while, or when a project behaves strangely.
See the sizes first
DiskJoy is our product. Its scan shows how large developer folders like these are on your Mac, read-only. The scanner does not delete anything and cleanup is not built yet, so DiskJoy does not remove any of these folders today. Use the scan to find the big ones, then clear them with the steps above.
Frequently asked questions
Why is Xcode taking up so much space?
Mostly because of DerivedData (build output and indexes for every project you have opened), simulators and their runtimes, and device support files for physical devices you have connected. All three grow over time and Xcode does not remove them for you.
How do I delete DerivedData?
Quit Xcode, then move the folder ~/Library/Developer/Xcode/DerivedData, or a single project folder inside it, to the Trash and empty the Trash. Xcode recreates it on the next build.
Can I delete old Xcode simulators?
Yes. Simulated devices and runtimes can be recreated or downloaded again. Apps and test data stored inside a simulated device are lost when you remove it.