Free up 20GB of space in 20 minutes
Quick ways to free space on your Xamarin Mac computer
Are you also trying to update to to the latest
XCode, but there’s no space on your MacBook Pro? Did you also think you would get by with the 128/256 GB SSD, but then you find out the “7GB” XCode unpacks into 20GB? I am sure you already tried to fiddle with the
Storage Management, but it wasn’t much help, and now you are wondering if it’s time to buy another Mac.
Not yet partner! Your MacBook still has many years on it, and now’s not the time to give up! Mac computers are expensive for a reason. There’s still several ways to save space, and I have collected the quickest steps that saved me >1GB (up to 5GB) each, and split this article into Xamarin, iOS, Android & Other Resources. Important points to keep in mind:
- The “
~” sign used in this article refers to the User folder that holds the Documents and Downloads folders, or “
Users/saamer/” in my case.
- You might need to enable viewing hidden files first. To view hidden files, just open
command+shift+.and those files and folders should appear. You can verify this by going here
Xamarin Temporary Files
The Visual Studio Download Cache
- I like to start with this one first. Make sure you check for the latest updates on Visual Studio and Install them before this step.
- Then, go to
~/Library/Caches/VisualStudio/-> And then in each of the Visual Studio versions, you can delete all the contents of the
TempDownloadfolder. Also delete the
Temporary Nuget packages
There can be two nuget caches you can get rid of:
- Go to
~/.nuget/packages/-> Select All -> Move to Trash
- Go to
~/.local/share/-> Select all folders -> Move to Trash
The bin & obj folders of your projects
Quit any iOS simulators & Android emulators if they are open. Now using your
Terminal, go to each of your Xamarin solution folders and just type in the command
git clean -fxd and hit
enter to delete all the temporary files- including everything that is in the nuget, bin and obj folders of all the projects
Archives you don’t need
- iOS Archives: Go to
~/Library/Developer/Xcode/Archives-> Select All -> Move to Trash
- Android Archives: Go to
~/Library/Developer/Xamarin/Archives-> Select All -> Move to Trash
iOS Temporary Cache
~/Library/Developer/CoreSimulator/Devices -> Select All -> Move to Trash
~/Library/Developer/CoreSimulator/Caches/dyld -> Select All -> Move to Trash
Device support for older OS versions
- iOS Archives: Go to
~/Library/Developer/Xcode/iOS Device Support-> Select All except current OS version-> Move to Trash
Note: This can save ~3.5 GB per OS version. You could delete the current OS version as well if you are getting support for the next version anyway
Cached iOS Designer files
~/Library/Caches/Xamarin/iOSDesigner and delete all the folders except the
Android Temporary Data
Emulator Cache and Unused Emulators
~/.android/cache and make sure it’s empty. -> Then go to
~/.android/avd/ and make there’s only AVD folders and INI files for the emulators you still want.
Android Studio’s “.m2” folder
I had installed Android Studio for it’s awesome tools for App Icons, but even though I had deleted Android Studio, there seemed to still be a sizable chunk of files that it left on my Mac. Just go to
~/.m2 and delete everything you see if you don’t have Android Studio anymore
Reset Emulator Data
You can also go one step further and reset all the emulators on your computer to Factory settings using Visual Studio.
Visual Studio-> Device Manager -> Settings-> Factory Reset
Disk Utility shows that your hard drive has a lot of Purgeable memory available, that is occupying unnecessary space, you can empty it using these steps that worked for me.
Et puis voilà! Once you’re done deleting everything, don’t forget to remove it from the Trash. Go to
~/Trash -> Delete All. You now have a lot more space available and should have no trouble installing what you need!
Git Objects folder
If you are using Git for source control, there’s a chance that after deleting the bin & obj folders and nuget packages, your app repository is still ~2GB in size. But when you add up the size of the remaining files, it’s supposed to be less than 50MB. If you look at the hidden files, you’ll notice the space occupied by the
objects directory of the hidden .git folder. As you can see here, you can run this command to shrink it:
git repack -a -d --depth=250 --window=250
Thank you to James Montemagno for “Cleaning Up Space on Your Xamarin Development Machine” and Charlin Agramonte for “Running out of space using Xamarin”. Their articles were a great starting point, and are the real MVP’s.