Xcode DerivedData taking up space: can you delete it?
Quit first: Xcode
Where it is
~/Library/Developer/Xcode/DerivedData
What it is
Xcode writes intermediate build files, compiled products, the source index used for code completion and navigation, and build logs into one folder per project inside DerivedData. Swift package checkouts that Xcode resolves for each project are kept there too.
Why it gets so big
Every project you've ever opened gets its own folder, and Xcode rarely cleans them up. Debug and release builds for several platforms and simulators add up, and folders for projects you've deleted stay behind.
Is it safe to delete?
Yes. Deleting DerivedData is the classic fix for strange Xcode build errors. The cost is a full rebuild and re-index the next time you open each project, plus re-resolving Swift packages. Quit Xcode first so it isn't in the middle of a build or indexing.
Tip
Xcode's Locations settings show the DerivedData path and include a shortcut to open it in Finder.
See how much space it uses
du -sh "$HOME/Library/Developer/Xcode/DerivedData" 2>/dev/nullDelete it by hand
Run in Terminal. Deleting cannot be undone, so check the paths first.
rm -rf "$HOME/Library/Developer/Xcode/DerivedData"/*