Skip to content

Instantly share code, notes, and snippets.

@whalemare
Created April 29, 2019 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whalemare/c58267400ae48ae172ba75f2409ea905 to your computer and use it in GitHub Desktop.
Save whalemare/c58267400ae48ae172ba75f2409ea905 to your computer and use it in GitHub Desktop.
React Native doctor that can solve your problems
#!/usr/bin/env bash
# If you dont know what happened just start this script for automatically trying solve your problem.
# Clear all your build folders and dependencies.
# Install dependencies again
platform=$1
platform=$(echo "$platform" | tr '[:upper:]' '[:lower:]') # to lower string
echo "Moving to the root project folder"
cd ..
echo "Remove npm dependencies"
rm -rf node_modules
echo "Clean watchman and npm cache"
watchman watch-del-all
npm cache clean
echo "Install npm dependencies"
npm install
if [[ "$platform" == "android" ]]
then
cd android
./gradlew clean
cd ..
elif [[ "$platform" == "ios" ]]
then
cd ios
echo "Start cleaning ios build"
rm -rf build
echo "Start cleaning ios pods"
rm -f Podfile.lock
rm -rf Pods
##
# Fix issue with precompile header errors caused by aggressive caching bug in XCode
# https://stackoverflow.com/questions/19391768/file-has-been-modified-since-the-precompiled-header-was-built
##
echo "Start cleaning XCode DerivedData"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod cache clean --all
echo "Cleaning successfully"
echo "Install and update pods"
pod update
pod install --repo-update
cd ..
fi
# be careful with this option. This can cause errors
#react-native link
@whalemare
Copy link
Author

whalemare commented Apr 29, 2019

Put this script inside root/scripts/{HERE}
Use this only inside script folder like:
cd scripts && ./doctor.sh ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment