Last active
August 23, 2023 04:05
-
-
Save jeroen-meijer/bc62dcc74e10e745be7b5790cf74edf0 to your computer and use it in GitHub Desktop.
Flutter Repair iOS - When your Flutter build comes up with weird Xcode errors, run this script from your Flutter project directory and it will clean out all the old iOS stuff and get your project dependencies fresh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# To run, download the script or copy the code to a '.sh' file (for example 'flutterrepair.sh') and run like any other script: | |
# sh ./flutterrepair.sh | |
# or | |
# sudo sh flutterrepair.sh | |
echo "Flutter Repair (by jeroen-meijer on GitHubGist)" | |
echo Cleaning project... | |
flutter clean 2>&1 >/dev/null | |
echo Updating Pod... | |
pod repo update | |
if ! ( "${PWD##*/}" == 'ios') | |
then cd ios | |
fi | |
echo Removing pod files... | |
rm -rf Podfile.lock Pods/ 2>&1 >/dev/null | |
cd .. | |
echo Removing cached flutter dependency files... | |
rm -rf .packages .flutter-plugins 2>&1 >/dev/null | |
echo Getting all flutter packages... | |
flutter packages get | |
cd ios | |
echo Running pod install... | |
pod install | |
cd .. | |
echo DONE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems a bit dangerous: if the
ios
directory isn't found, then it simply doesn't change dir, and continues the script. Wouldn't it be better to check at the beginning, and make sure it's invoked in the right directory?I'd also suggest adding
set -e
at the start of the script, so it aborts if it encounters an error.