I am running low on disk space and checked through a third party utility that among other things that ~/Library/Developer/Xcode/DerivedData directory is taking about 22GB of disk space.
I searched stackoverflow and found this post
How can I safely delete in my ~/Library/Developer/Xcode/DerivedData directory?
The accepted answer to this question suggests that I should not touch / remove folders from this directory. so what I did was
- Found an existing build project folder for an app that I have available on Appstore
- Deleted the folder from derived dir
- launched XCode 5
- Open that project
- Clean Build
- Tested and compiled it on a simulator
- ReArchived
- Everything worked. Nothing was broken.
Unless I missed something in that posts answer I want to make sure by asking experienced developers that if I delete all the folders from DerivedData it will not hurt me in building, testing and compiling those projects.
I purge derivedData often enough that I have an alias for it. It can fix build problems. I have the following in /Users/Myusername/.bash_profile
Then in terminal, I type purgeallbuilds, and all subfolders of DerivedData are deleted.
XCODE 10 UPDATE
On the tab:
You can access all derived data and clear by deleting them.
~/Library/Developer/Xcode/DerivedData
shows at least two folders are huge:
Feel free to remove stuff in the folders:
and some in:
yes, safe to delete, my script searches and nukes every instance it finds, easily modified to a local directory
I would say it's safe--I often delete the contents of the folder for many kind of iOS projects, this way. And, I haven't had any issues with builds or submitting to the App Store. The procedure deletes derived data and cleans a project's cached assets, for both Xcode 5 and 6.
Sometimes, simply calling rm -rf on the Derived Data directory leaves a lingering file or two, but my script loops until all files are deleted.