dotnetco.de
Not enough disk space

Clean up my mac and free space for Xamarin Developers

Not enough disk space

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

Lots of Folders to delete

Most of the tips are retrieved from several existing articles which are for example:

So now delete all the files and folders in these directories within base directory /Users/yourname :

  • ~/.nuget/packages
  • ~/local/share
  • ~/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/CoreSimulator/Devices
  • ~/Library/Developer/CoreSimulator/Caches/dyld
  • ~/Library/Developer/XCode/iOS Device Support (delete all except your current version)
  • ~/Library/Caches/Xamarin/iOS Designer (everything except device_set.plist)
  • ~/.android/cache
  • ~/.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
    • VisualStudio/Version/TempDownload
  • ~/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

Uninstall XCode

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 πŸ™‚

6 Comments

  1. I work on Windows most of the time. The Mac is only used as iOS Build Host. I have Xcode, VS, VS code, Chrome and NOTHING else. And still a few months ago my 500GB disk was full.

    I didn’t do all the work you did and searched which folders hold all that outdated data. I reinstalled MacOS. And now there are 400GB free again. I don’t know if all that crap was in one of the folders listed above.

    If you still don’t have enough disk space, consider reinstalling the whole machine.

    1. But “buy a larger device” would be a rather short blog post,right?πŸ˜‰ And in all the years I learned that a hard drive is NEVER large enough …. My first HDD had 40 MB(!) and I thought this would be enough for decades πŸ˜‚ So it is always nice to fix problems with money, but sometimes other options are available,too.

    2. Maybe so but when a 1TB to 2TB SSD for a 2015 MBP with a broken screen probably costs like $300 to $800; I just can’t justify it! (Especially since I’m not an Android developer, at the moment, and could probably use my Windows laptop if I needed to be.) So, this freed 16,681 MB! (Keeping Versions/12.6.0.25 and 15.8.0.3, just in case.)

      sudo rm -rf /Library/Frameworks/Xamarin.*/*/[5678].*

  2. I still think that developers should think on buying larger storage, even though you’re not approving my comments πŸ˜‰

Leave a Comment