Cleaning out DerivedData

Categories:

Did you ever wonder what Xcode was doing when the activity viewer (bet you didn’t know it was called that) area says “Indexing | Processing files”?

tut_activity_viewer

Well, other than the obvious (it’s indexing), it’s also filling up your hard drive with what it refers to as derived data. This derived data contains all manner of information and assets associated with the project such as intermediate builds, precompiled objects, indexes (metadata about the project), etc. All this information takes up space; a simple project with nothing more than a single view controller generated 15 megabytes of derived data, over 50 times the amount of space for the project folder itself!

If you’re like me you create and forget about iOS projects frequently (perhaps you’re blogging or you just like creating applications to learn new techniques or are following along online tutorials). One can easily lose track of how much wasted space of derived data from old projects is sitting out there.

Fortunately it’s easy to get rid of and clean up. Simply go to your Xcode DerivedData folder and delete everything in it:

cd ~/Library/Developer/Xcode/DerivedData
rm -rf *

Now this will trigger a reindexing on your projects, but only when you reopen them. I suppose I’m a packrat; my DerivedData folder had grown to 16 gigabytes, mostly from old projects.

There may be other DerivedData folders lurking on your disk if you’ve used relative derived data folders in the past for your projects (that is, the DerivedData folder hangs out in your project folder rather than a central location in ~/Library/Developer/Xcode). You can find and delete them with something like this:

cd ~/projects
find . -name 'DerivedData' | xargs rm -rf

I keep all of my Xcode projects in a folder called projects. If you keep yours in Documents or some other location, change to that directory first before searching for DerivedData with find.

As always, take care when using xargs rm -rf.

Leave a Reply

Your email address will not be published. Required fields are marked *