Last active
September 29, 2021 19:38
-
-
Save swiftyfinch/53c76e2faff3de83371193468380e90c to your computer and use it in GitHub Desktop.
Cozy pod install. https://swiftyfinch.github.io/en/2020-05-23-cozy-pod-install/
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
#------------------------------------------------------------------------------- | |
# CocoaPods | |
#------------------------------------------------------------------------------- | |
function pods_install() { | |
red="\001$(tput setaf 1)\002" | |
yellow="\001$(tput setaf 3)\002" | |
green="\001$(tput setaf 2)\002" | |
reset="\001$(tput sgr0)\002" | |
if [ "$1" = "-f" ] ; then | |
shift 1; | |
else | |
diff "Podfile.lock" "Pods/Manifest.lock" > /dev/null | |
if (( $? == 0 )) ; then | |
echo -e "🎉 ${green}Everything is up to date.${reset}" | |
return | |
fi | |
fi | |
tries=2 | |
while (( $tries > 0 )) | |
do | |
bundle exec pod install "$@" | |
error=$? | |
if (( error == 7 )) ; then | |
echo -e "\n${red}⚠️ Error code: ${error}${reset}" | |
echo -e "${yellow}🚑 Let's try bundle install${reset}\n" | |
bundle install | |
elif (( error == 31 )) ; then | |
echo -e "\n${red}⚠️ Error code: ${error}${reset}" | |
echo -e "${yellow}🚑 Let's try --repo-update${reset}\n" | |
bundle exec pod install --repo-update | |
elif (( error != 0 )) ; then | |
echo -e "\n${red}⚠️ Error code: ${error}${reset}" | |
break | |
else | |
echo -e "🎉 ${green}Everything fine.${reset}" | |
break | |
fi | |
tries=$(( $tries - 1 )) | |
done | |
tput bel | |
unset red yellow reset tries | |
} | |
function pods() { | |
case $* in | |
install! ) shift 1; pods_install -f "$@" ;; | |
install ) shift 1; pods_install "$@" ;; | |
* ) command bundle exec pod "$@" ;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment