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
π¦ 2. Old Archives
Old .xcarchive
files pile up with every TestFlight or App Store build.
rm -rf ~/Library/Developer/Xcode/Archives/*
π 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/*
π± 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/*
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
βοΈ React Native & Node Cleanup
π 6. Metro & Watchman Caches
watchman watch-del-all 2>/dev/null
rm -rf ~/Library/Caches/metro*
rm -rf ~/Library/Metro
π¦ 7. npm / yarn / pnpm Cache
npm cache clean --force
yarn cache clean
pnpm store prune
π‘ 8. Project node_modules
(Optional)
rm -rf node_modules && npm install
π« CocoaPods (for iOS builds)
Caches dependencies that can be safely redownloaded.
rm -rf ~/Library/Caches/CocoaPods
rm -rf ~/.cocoapods
π€ Android / Java Cleanup
βοΈ 9. Gradle Caches & Build Artifacts
rm -rf ~/.gradle/caches
rm -rf ~/.gradle/daemon
rm -rf ~/.android/build-cache
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/*
π§© 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 .."
}
Now I can simply run:
npm run cleanBuild
or
yarn cleanBuild
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
π 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)