Mantravali / Junkless / Guide
Xcode Taking Up Too Much Space? How to Clean DerivedData and Simulators
Xcode is one of the most common reasons a developer's Mac runs out of space. The app itself is large, but the bigger cost is what it builds up over time: build output for every project you have opened, simulator runtimes for several iOS versions, debug symbols for every device you have connected, and archives of every release. Most of it is safe to remove, but not all of it, and some of it Xcode can only rebuild slowly.
See what is taking the space
This Terminal command only reads sizes; it doesn't change anything. Open Terminal from Applications, then Utilities, and paste:
du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator 2>/dev/null
You'll see a size for each folder below. On a Mac that has been used for iOS development for a while, tens of gigabytes is normal.
DerivedData: safe to delete
~/Library/Developer/Xcode/DerivedData holds build output and indexes for every project you have opened, including projects you deleted long ago. It is usually the biggest folder, and it is safe to delete. Quit Xcode first. The next build of each project starts from scratch, so it will be slower once, and Xcode will re-index the project.
To find it, open Xcode's settings, go to Locations, and click the arrow next to the Derived Data path to show it in Finder. To clean only the project you have open, use Product, then Clean Build Folder.
Simulators and simulator runtimes
Each iOS, watchOS or visionOS simulator runtime takes several gigabytes, and each simulator device keeps its own apps and data.
- Runtimes you no longer need. In Xcode's settings, open Components (called Platforms in some versions) and remove old runtimes. You can download them again later if a project needs them.
- Simulators for runtimes that are gone. After removing runtimes, this command deletes simulator devices that can no longer run: xcrun simctl delete unavailable. It only removes devices marked unavailable.
- Simulators you don't use. In Xcode, choose Window, then Devices and Simulators, select the Simulators tab, and delete devices you don't need. Their installed apps and data go with them.
Device support files
When you connect an iPhone or iPad to run an app from Xcode, Xcode copies debug symbols for that device's iOS version. They live in folders such as ~/Library/Developer/Xcode/iOS DeviceSupport, with one folder per version, often several gigabytes each. Folders for iOS versions your devices no longer run are safe to delete. If you connect a device on that version again, Xcode copies the symbols again, which takes a few minutes.
Archives: keep the ones you shipped
~/Library/Developer/Xcode/Archives holds every build you archived for TestFlight or the App Store, including its debug symbols. Those symbols are what turn crash reports from that build into readable stack traces. Delete old test archives freely, but keep the archive for each version people still use, unless you have kept its dSYM files somewhere else. Manage them in Xcode's Window, then Organizer.
Package and tool caches
- Swift packages. Downloaded package sources are cached in ~/Library/Caches/org.swift.swiftpm, and each project also keeps a copy inside its DerivedData folder. Both are downloaded again when needed.
- CocoaPods and Carthage. If you use them, their caches in ~/Library/Caches can be cleared the same way, and they re-download on the next install.
- Simulator caches. ~/Library/Developer/CoreSimulator/Caches holds caches that are rebuilt when needed.
Quit Xcode and the Simulator before removing any of these folders. Move them to the Trash rather than deleting with rm, so you can put something back if a project stops building.
Build folders inside your projects
Outside Xcode's own folders, project directories collect their own rebuildable output: build folders, node_modules in web projects, Pods, and Python virtual environments. Across a few dozen old projects, these add up. Each can be recreated from the project's own files, but check first that a folder really is generated output and not something you committed by hand.
Junkless has a Developer Projects scan that finds rebuildable folders such as build output and dependency caches in the folders you choose. Source code and .git can never be selected, and everything it removes goes to the Trash so you can restore it.