Unfortunately I nowadays often run into the problem of missing free space on my macbook (from 2015, 256 GB) when I want to upgrade XCode or Mac OS. Typically I uninstall XCode first so I was able to install Big Sur today. Now I have to reinstall XCode, but even with 38 GB of free space, AppStore still complains that there is not enough free space to install these 11 GBs…. So here are the steps I did to clean up my mac. Always helpful: Clean your trash bin and do a restart after big deletions (especially after uninstalling XCode).
Using free Tools to free space
Of course there are tools promising to do it all for you but maybe they are not designed to take care of all the Xamarin stuff. You will probably find them easy with Google, so here are just the tools I use
- Omnidisk Sweeper is a nice tool to show folder sizes
- Commander One has a simple switch to show hidden files.
- Clean & Compress easily deletes all bin, obj and packages of your Xamarin Projects
Lots of Folders to delete
Most of the tips are retrieved from several existing articles which are for example:
- Quick ways to free space on your Xamarin Mac computer
- 10 Ways to free up disk space on your Mac Hard Drive
- Cleaning up space on your Xamarin Dev Machine
So now delete all the files and folders in these directories within base directory /Users/yourname :
- ~/Library/Developer/XCode/Archives (delete all the archives you don’t need)
- ~/Library/Developer/Xamarin/Archives (delete all the archives you don’t need)
- ~/Library/Developer/XCode/iOS Device Support (delete all except your current version)
- ~/Library/Caches/Xamarin/iOS Designer (everything except device_set.plist)
- ~/.android/avd (delete all devices you don’t need)
- ~/Library/Caches (check the data you don’t need anymore. With Omnidisk Sweeper you could sort by size and identifiy large stuff easy, e.g.
- old Jetbrains Rider installations
- ~/Library/Application Support same as above: Identify largest directories and see what you still need.
Deleting bin, obj and packages easily
Go to your projects folder, right-click the folder and select “Clean” from Services (if you have installed Clean & Compress Tool as mentioned above). Done!
Resetting Android Devices (Factory Reset)
In /.android/avd/pixel_3a I’ve seen a userdata-qemu.img with 6,4 GB and a userdata-qemu.img.qcow2 with 6,2 GB. With deleting the .img you just reset the simulator (see O’Reilly) so that could be deleted. Instead of deleting, starting the app “Android Devices” and doing a Factory Reset there might be a better option. After that, my directory size for Pixel 3a went down from 13,92 GB to 1,29 GB! My Pixel 3 emulator (which I do not use too often) also went down from 3,59 GB to 1,18 GB.
Remove old Xamarin Frameworks
Library/Frameworks/Xamarin.Android.Framework uses 21,7GB in my case. There are lots of old frameworks which could be deleted, according to this answer from Jon Goldberger in Xamarin Forums. You only need to keep the frameworks you still use, so latest one as minimum of course. Typically you could identify the latest framework by it’s number, but you could also run this command in terminal to be sure: ls -la /Library/Frameworks/Xamarin.Android.framework/Versions/Current You could do the same for Xamarin.Mac.framework, Xamarin.iOS.framework and Mono.framework.
Delete iOS Simulators
As mentioned by Pavel Kovalev, you could use some xcrun commands to find and delete iOS simulators. Additionally make sure to check /Library/Developer/CoreSimulator/Profiles/Runtime which takes 16GB in my case.
- list all simulators: xcrun simctl list devices
- delete specific device: xcrun simctl delete [device udid]
- delete all devices which are not supported anymore: xcrun simctl delete unavailable
If that still does not bring you enough free space to update XCode: Uninstall XCode and reinstall it fresh from the app store. Most settings are kept even after uninstall (e.g. simulators are still available), and mainly XCode is only used to get the Xamarin iOS app building so it just takes 1-2 minutes to start after reinstall. And for me, XCode takes 29GB according to application list so that’s a big win! After uninstalling, give your mac some minutes to clean up, and then reinstall XCode from AppStore.
And don’t forget to clean your trash bin frequently 🙂