Created
October 25, 2021 22:47
-
-
Save vilanovi/95b8c92016f1b9d8102cc8164b3e8750 to your computer and use it in GitHub Desktop.
Runs pod install on the same version of the Podfile.lock, installing cocoapods version via gem if not installed.
This file contains hidden or 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/bash | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
if test -f "Podfile.lock"; | |
then | |
VALUE=`cat Podfile.lock | grep COCOAPODS` | |
POD_VER=$(echo $VALUE | sed 's/COCOAPODS: //g') | |
if test -z "$POD_VER" | |
then | |
echo "No Podfile.lock has been found." | |
echo "" | |
echo "${bold}pod install${normal}" | |
pod install | |
else | |
echo "Podfile.lock found using cocoapods version $POD_VER" | |
GEM_VER=`gem list --local | grep 'cocoapods (' | sed 's/cocoapods (//g' | sed 's/)//g' | tr ', ' '\n' | grep $POD_VER` | |
if test -z "$GEM_VER" | |
then | |
echo "Cocoapods $POD_VER is not currently installed in your system." | |
echo "Installing cocoapods $POD_VER:" | |
echo "" | |
echo "${bold}sudo gem install cocoapods -v $POD_VER${normal}" | |
if sudo gem install cocoapods -v $POD_VER; then | |
echo "" | |
echo "Cocoapods $POD_VER successfully installed." | |
else | |
echo "" | |
echo "Failed to install cocoapods $POD_VER. Please, read the log above to debug the problem." | |
exit 1 | |
fi | |
fi | |
echo "" | |
echo "${bold}pod _${POD_VER}_ install${normal}" | |
pod _${POD_VER}_ install | |
fi | |
else | |
echo "No Podfile.lock has been found." | |
echo "" | |
echo "${bold}pod install${normal}" | |
pod install | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment