Tip: iOS devs, reclaim your SSD space back!
by Lukas Kukacka
If you have been developing for iOS on your Mac for a while, chances are you can free up some of your precious SSD space with no pain.
How much available space can you get back? Up to tens of GBs, depending mainly on how long you have been developing for iOS…
What is taking all that space on my SSD?
There are many advanced apps to give you an overview of your SSD usage. However, you can get a lot of insights with a simple shell command:
How it works:
- Show disk usage (
du
) of all folders and files in current directory (./*
), show total summary for each item (-s
) in human-readable format (-h
). - Sort output (
sort
) by numeric value taking into account human-readable format (-h
).
Run it every now and then inside your home folder and just follow the trail of too big folders from there, going deeper.
I did just that to find iOS development related resources I could delete…
How do I get my SSD space back?
Your Mac contains a lot of folders, spreaded across filesystem, containing resources related to iOS development. Many of those can contain resources which you might not need anymore. This article will give you an overview of some of these folders. It is then up to you to decide what to delete… I don’t take any responsibility for any eventual damage or loss!
Before you delete anything from these locations, you should close Xcode and iOS Simulator, just in case…
Note on using Time Machine
If you are using Time Machine backups, you might not see the free space immediately after deleting files. From my experience, Finder does not show extra free space after deleting files until next Time Machine backup was finished.
You could also consider excluding some of the locations mentioned in this article from your Time Machine backups. That could speed up your backups and save you some backup disk space. Most of these locations are anyway either caches or can be downloaded again.
Location of iOS development related resources
DerivedData
Location: ~/Library/Developer/Xcode/DerivedData
(default)
Everyone knows DerivedData folder. It contains artifacts and caches / temporary files for each build. Deleting it is usually the first thing we do when facing unexpected build failures.
Deleting contents of DerivedData is safe and it can get a lot of space back, depending on how many projects you have built since it was empty last time. Be aware that after deleting DerivedData you will have to rebuild each project from scratch.
iOS Simulator runtimes
Location: /Library/Developer/CoreSimulator/Profiles/Runtimes
Each Xcode comes with preloaded Simulator for latest iOS version. You can install additional Simulators in Xcode -> Preferences -> Components. Every additionally installed Simulator is here.
You can safely delete any Simulator version you don’t need anymore. Don’t worry, you can always re-install it again from Preferences.
As you can see, these are taking quite a lot of space. In my case deleting everything pre-iOS 10 would give me back 11+ GB.
iOS DeviceSupport
Location: ~/Library/Developer/Xcode/iOS DeviceSupport/
Check rmaddy’s answer at StackOverflow explaining contents of this folder. Quoting the answer:
The
~/Library/Developer/Xcode/iOS DeviceSupport
folder is basically only needed to symbolicate crash logs.You could completely purge the entire folder. Of course the next time you connect one of your devices, Xcode would redownload the symbol data from the device.
Deleting contents of this folder from time to time can give you a lot of space back. Depending on the amount of devices you were connecting to your Xcode, it can be up to tens of GBs (as you can see in StackOverflow comments).
CoreSimulator logs
Location: ~/Library/Logs/CoreSimulator
iOS Simulator saves logs to this folder. Deleting logs should be safe.
Logs folder might not sound interesting, but eventually could take a lot of space. Simulator’s Safari log taking over 5GB was very surprising to me…
Xcode Downloads cache
Location: ~/Library/Caches/com.apple.dt.Xcode/Downloads
This is a temporary location of all Xcode downloads. When installing additional Simulators from Xcode -> Preferences -> Components, Xcode first downloads installer .dmg here and then installs Simulator from it. Installers seems to be kept even after the installation. Once the Simulator is installed, should be safe to delete these installers.
Xcode Archives
Location: ~/Library/Developer/Xcode/Archives
Archives from Xcode -> Window -> Organizer -> Archives are stored here. These are .xcarchive packages of our application, result of Xcode -> Product -> Archive, most often ready for submission to App Store Connect. You can eventually have archives you don’t need anymore.
WARNING: If you want to delete archives, be extremely careful. Be absolutely sure you want to do that and that it cannot cause you any harm. Archives, among others, contain dSYMs you need for symbolicating your crash reports (from my experience these are sometimes needed even if you use Bitcode and download dSYMs from App Store Connect).
Speaking of which, as a best practice, you should consider always backing up your archives somewhere outside your Mac.
Carthage DerivedData
Location: ~/Library/Caches/org.carthage.CarthageKit
Carthage dependency manager seems to store its DerivedData in Caches, not the standard ~/Library/Developer/Xcode/DerivedData
location.
If you are using Carthage, you might get some space by deleting its DerivedData and additionally other folders. Be aware that next time you will call carthage update
, it will take some time as it will rebuild (and eventually re-download) all dependencies.
Did you get your available space back?
I hope this article gave you a good overview of where Xcode stores various disposable files and maybe helped you to get some available SSD space back.
How much space did you get back? Do you know any other locations this article should mention? Let me know via Twitter ↓
Like the article, got a comment or found an issue? Get in touch via Twitter .
Subscribe via RSS