Created
June 27, 2016 23:12
-
-
Save aavina/240e8e052558349625ee9e1c82f96422 to your computer and use it in GitHub Desktop.
Carthage Cartfile diff script
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
function runCarthageAndCopyResolved { | |
echo "Running Carthage.." | |
/usr/local/bin/carthage bootstrap "$SRCROOT" --platform iOS | |
# Copies the Cartfile.resolved file to /Carthage directory | |
cp "$SRCROOT"/Cartfile.resolved "$SRCROOT"/Carthage/.Cartfile.resolved | |
echo "Copied Cartfile.resolved to /Carthage directory." | |
echo "This will be used to check Carthage dependency updates in the future." | |
} | |
command -v carthage >/dev/null 2>&1 || { | |
echo "Carthage is required. Please install Carthage and try again. Aborting."; | |
exit 1; | |
} | |
# Checks if Carthage/Build directory doesn't exist and if not it'll run Carthage | |
# After, it checks if the Cartfile.resolved file differs from the one in Carthage. If so, Carthage runs | |
if [ ! -d "$SRCROOT/Carthage/Build" ]; then | |
echo "No Carthage/Build directory found." | |
runCarthageAndCopyResolved | |
elif [ -f $SRCROOT/Carthage/.Cartfile.resolved ] && \ | |
diff $SRCROOT/Carthage/.Cartfile.resolved \ | |
$SRCROOT/Cartfile.resolved >/dev/null ; then | |
echo "Cartfile.resolved has not changed. Building project." | |
else | |
echo "Cartfile.resolved not up to date or not found." | |
runCarthageAndCopyResolved | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment