DEV Community

Cover image for Free space in your Mac for Mobile Development
David Amunga
David Amunga

Posted on

Free space in your Mac for Mobile Development

Once every few months i perform the much needed relieving task of freeing disk space out of my 256GB Mac. I often use CleanMyMac is an ideal software for periodically cleaning out your disk space with some added performance and security optimisations. However when you wan't to clean out your dev environment it takes a few manual commands to get the job done since disk cleaner software won't know what to clear. You'd be surprised how much space you recover after clearing out unused dev resources. This article describes how to free storage space for Mobile Developement in a Mac laptop.

Android

1. Clean up Gradle

Your Gradle Home directory contains wrapper ,caches and daemons files. The more projects with diffferent gradle versions the more subdirectories within those three folders. You can delete all three directories. This saved me a cool ~12GB of space.

You could run the command as below to achieve the desired result.



cd ~/.gradle
rm -rf caches daemon wrapper

Enter fullscreen mode Exit fullscreen mode



  1. Android SDK Cleaning

Android System images are only used by emulators. If you use a real Android device during development for debugging, you no longer need them, so you can remove them all. This could easily save you 5GB doing this.

Android Studio SDK Manager<br>
Android Studio SDK Manager

iOS

Its easy to run out of space while doing iOS Development since Xcode loves to cache things everywhere around your Mac. It gets even complicated once Xcode has an update(~11GB) but realistically its around ~40GB free space required to download and install the update. Sadly i've had to delete Xcode and install it again to make it work again.

Xcode Update
Xcode Update Space Error🙃

1. Remove Old Simulators

As with Android the major culprit will be old simulators that take alot of space. The simulator files are by default located in ~/Library/Developer/Xcode/iOS/Device Support folder. You can delete old simulators using the following command.



xcrun simctl delete unavailable

Enter fullscreen mode Exit fullscreen mode



  1. Remove Cocoapod Caches

If you use Cocoapods in your projects you can clear them using this command. Don't worry you can rebuild them later again.



rm -rf "${HOME}/Library/Caches/CocoaPods"

Enter fullscreen mode Exit fullscreen mode



  1. Clean up Archives,Logs and DerivedData folders

Folders like DerivedData can take up a significant amount of space too. DerivedData is generated during each build process. This contains intermediate build results,indexes that speed up time on each build. You can use the command below to clear all that data.



rm -rf ~/Library/Developer/Xcode/Archives
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~~/Library/Developer/Xcode/iOS Device Logs/

Enter fullscreen mode Exit fullscreen mode




DevCleaner for Mac

If you're not to keen in heading to this article again to clean up your iOS Development workspace, you can download this DevCleaner by One Minute Games that handles it superbly.

DevCleaner App UI

Conclusion

Don't forget to empty your trash to check out how much space you have available. I was able to clear around ~15GB after doing this. I hope this also works for you. You can recommend other tools or ways you've found that has freed space for mobile development. It would be cool to add it to the article.

Top comments (0)