DEV Community

Ajmal Hasan
Ajmal Hasan

Posted on

🧹 How I Freed Up Half My Mac Storage as a React Native Developer

As a React Native developer, I constantly build for both iOS and Android, which means my machine takes a beating from Xcode, simulators, Gradle builds, node modules, and caches.

Recently, I noticed that my 512GB SSD was nearly full β€” and when I checked, Xcode alone was consuming over 85 GB! 😱

So, I decided to do a full cleanup.
After running a few terminal commands and deleting unneeded build data, I freed up half my disk space. Here’s what I did πŸ‘‡


πŸ’£ The Hidden Storage Hogs

🧩 1. Xcode Build Data & Indexes

These files rebuild every time you open or compile a project β€” so it’s completely safe to delete them.

rm -rf ~/Library/Developer/Xcode/DerivedData
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ 2. Old Archives

Old .xcarchive files pile up with every TestFlight or App Store build.

rm -rf ~/Library/Developer/Xcode/Archives/*
Enter fullscreen mode Exit fullscreen mode

πŸ” 3. DeviceSupport Files

Every time you connect an iPhone or test a new iOS version, Xcode downloads symbol data.

rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
Enter fullscreen mode Exit fullscreen mode

πŸ“± 4. Simulator Devices & Cache

Each simulator keeps its own storage, logs, and app data.

rm -rf ~/Library/Developer/CoreSimulator/Devices/*
rm -rf ~/Library/Developer/CoreSimulator/Caches/*
Enter fullscreen mode Exit fullscreen mode

You can also remove unused runtimes from
Simulator β†’ Settings β†’ Runtimes or
Window β†’ Devices and Runtimes β†’ Delete unused devices.


⚑ 5. Xcode Cache

Recreated automatically after you relaunch Xcode.

rm -rf ~/Library/Caches/com.apple.dt.Xcode
Enter fullscreen mode Exit fullscreen mode

βš™οΈ React Native & Node Cleanup

πŸŒ€ 6. Metro & Watchman Caches

watchman watch-del-all 2>/dev/null
rm -rf ~/Library/Caches/metro*
rm -rf ~/Library/Metro
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ 7. npm / yarn / pnpm Cache

npm cache clean --force
yarn cache clean
pnpm store prune
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ 8. Project node_modules (Optional)

rm -rf node_modules && npm install
Enter fullscreen mode Exit fullscreen mode

🍫 CocoaPods (for iOS builds)

Caches dependencies that can be safely redownloaded.

rm -rf ~/Library/Caches/CocoaPods
rm -rf ~/.cocoapods
Enter fullscreen mode Exit fullscreen mode

πŸ€– Android / Java Cleanup

βš™οΈ 9. Gradle Caches & Build Artifacts

rm -rf ~/.gradle/caches
rm -rf ~/.gradle/daemon
rm -rf ~/.android/build-cache
Enter fullscreen mode Exit fullscreen mode

Delete unused AVDs (emulators) from
Android Studio β†’ Device Manager
and unused system images via SDK Manager.


🧰 10. Other Optional Cleanups

# Homebrew cleanup
brew cleanup -s

# CocoaPods Specs repo
rm -rf ~/.cocoapods/repos

# Xcode docs
rm -rf ~/Library/Developer/Shared/Documentation/*
Enter fullscreen mode Exit fullscreen mode

🧩 Project-Level Cleanup Command (Run on projects that you are not working on)

For day-to-day development cleanup, I also added this handy script inside my package.json:

"scripts": {
  "cleanBuild": "rm -rf .jso node_modules Gemfile.lock && cd ios && rm -rf build Pods .xcode.env.local Podfile.lock && cd .. && cd android && rm -rf build .gradle && cd app && rm -rf development build .cxx && cd .. && cd .."
}
Enter fullscreen mode Exit fullscreen mode

Now I can simply run:

npm run cleanBuild
Enter fullscreen mode Exit fullscreen mode

or

yarn cleanBuild
Enter fullscreen mode Exit fullscreen mode

to completely wipe build artifacts for both iOS and Android.


βœ… The Results

After deleting:

  • DerivedData (85+ GB)
  • Old simulator data (10+ GB)
  • CocoaPods and Gradle caches

My system went from almost full to over 50% free space.
Xcode now opens faster, simulators load instantly, and builds are cleaner.


🧠 Pro Tip: Automate It

Create a file named clean-dev-space.sh and add all the commands above.
Then simply run:

bash clean-dev-space.sh
Enter fullscreen mode Exit fullscreen mode

πŸš€ Final Thoughts

If you’re a React Native developer juggling iOS and Android, your Mac silently collects tens of gigabytes of temporary build data every month.
Cleaning up regularly not only saves space but also improves build speed and performance.

I freed up half my storage with a few terminal commands β€” and now my Mac feels brand new again. ✨

Top comments (0)