How to Clean Your Disk for Free Space
If you do iOS, Android and React Native development on your Mac, chances are you are easily using up your 256GB of storage space with various caches.
If you work on a React Native based mobile app, you most likely are using a Mac to be able to test your app on iOS as well. This means that even though the SSD is very fast, it is either 128GB or 256GB. This can get easily filled up due to various caches that are made by various build systems.
This article will point you to the right places to help clear up the caches and rebuild only what is needed.
First, go to > About this Mac > Storage and then choose “Manage…” on top right.
Now choose “Review Files” on bottom left and then select the File Browser tab. At first glance, you will notice that in the left sidebar, it will show that majority of the disk space is consumed by the “Other” category.
This is because all the cache directories are in the home folder and are hidden folders starting with a dot in the name. This causes them to not be easily searchable.
The fix to getting the system to list all hidden folder as well is to press CMD + SHIFT + .
— this will cause all the dot folders to also show up. Now it will begin calculating the size of each directory and updating the list.
You can safely get rid of the following directories by right clicking and selecting Move to Bin
option:
~/.npm
— npm cache~/.yarn
and~/Library/Caches/Yarn
— Yarn cache~/.gradle
— Gradle cache~/.m2
— Maven cache~/.cocoapods
and~/Library/Caches/CocoaPods
— CocoaPods cache~/.nvm
— Node Version Manager cache~/.android
— Android cache~/Library/Caches/Homebrew/downloads
— Homebrew cache~/Library/Developer/Xcode
— Xcode cache~/Library/Developer/CoreSimulator
— iOS Simulator cache
In addition to all of these, in your individual project repos, you can delete these folders of less used projects, they can be easily recreated if needed:
node_modules
— Just runnpm install
again when neededandroid/app/build
— Just rebuild the Android app when needed
After deleting all the folders above, you should easily be able to reclaim around 100GB of free space. Make sure to run the following command in your primary project to rebuild the caches — this will take time the first time.
npm install
oryarn
in your primary projectspod install
in your project’s iOS directory.gradlew build
in your project’s Android
With all of this done, you should have a lot of free space for many weeks before the caches begin to fill up again! Then you can come refer back to this guide to help free up disk space on your Mac laptop.
Thank you post
You can go further and delete the entire ~/Library/Caches/Homebrew folder.