It's easy to run out of disk space when you are doing iOS development on your Mac, especially if your Mac has only 128GB of storage.
Ever gotten this warning when you want to update Xcode? I hope not! 😱
We will discuss what causes your mac storage to be filled quickly and what you can do to solve them in this article.
TL;DR Jump to DevCleaner app
Usually the main culprit taking up space will be the iOS Simulators. As you download newer version of iOS Simulator incrementally (iOS 10, 11 , then 12), the space add up as the old simulators file still remain.
The Simulator files are usually located in ~/Library/Developer/Xcode/iOS DeviceSupport/.
Open Finder, press Command + Shift + G , paste in
~/Library/Developer/Xcode/iOS DeviceSupport/ and press Enter. You should see multiple folder containing different iOS version of simulators. You can delete unused older version of simulator here. These files can take up to dozens of GBs, be sure to check these every time a new iOS version is introduced.
You can also delete old simulator by running this command in the terminal :
xcrun simctl delete unavailable .
The second culprit will be App Archives. These are created every time you archive an app, these can build up slowly as you archive different version of your apps.
To delete these archive data in Xcode, select Window > Organizer > Archives from top menu. Then press delete to remove them.
App archives can take up significant space if your app is large in size, a rough calculation would be taking your app size and multiply it by the number of time you have archived.
Last but not least, derived data can take up significant space too. Derived data is generated during each app build process. Derived data contains intermediate build results, generated indexes, that help speed up build time.
You can think of derived data as cached data/image in web browser, most of the time web browser will auto-save the data/image into your hard disk when you first browse a web page, and the next time you visit the same web page, the pageload speed is faster as web browser will use the cached data /image in hard disk.
Similar to iOS Simulator, derived data is located in ~/Library/Developer/Xcode/DerivedData , you can safely delete them. To delete derived data of the current open Xcode project, you can hold alt, click Product > Clean Build Folder.
It can be a hassle to clean up simulators, archive data and derived data manually once in a while.
Fortunately, there's a free Mac app by Konrad which can handle these at ease.
Dev Cleaner allow us to select which data to remove easily :
I have been using DevCleaner for a while and really like its simplicity, kudos to Konran for making this app.