Skip to content

Instantly share code, notes, and snippets.

@evgenyneu
Last active August 21, 2018 15:23
Show Gist options
  • Save evgenyneu/547e2b65f86e375cbefc to your computer and use it in GitHub Desktop.
Save evgenyneu/547e2b65f86e375cbefc to your computer and use it in GitHub Desktop.
Undo frameworks built by Carthage except the one given framework
#!/bin/sh
#
# Script for Xcode and Carthage
# ------------------------------
#
# Dismisses changes to all the frameworks except the given frameworks in the iOS build folder.
# This is used to undo the changes done to the framework build after `carthage update` command.
#
#
# Usage
# ------
#
# For example, undo changes to all frameworks except KIF and Quick.
# This is executed from the root Xcode project folder:
#
# ./undo_ios_carthage_except.sh kif quick
#
# The supplied framework names:
# 1. Are case insensitive.
# 2. Can be partial: "http" will keep OHHTTPStubs framework.
#
# Make string comparison case insensitive
shopt -s nocaseglob
# Check if arguments are correct
# ------------
if [ "$#" -lt 1 ]
then
echo "\nUsage:\n"
echo " ./undo_carthage_except.sh name name name\n"
exit 1
fi
git checkout Carthage/Build/Mac --force
# Go through all iOS framework folders
# ------------
for framework in `find Carthage/Build/iOS -iname *.framework`;
do
keep=false
# Check if arguments match the framework path
# ------------
for arg
do
exception=${arg[$i]}
if [[ $framework =~ $exception ]]
then
keep=true
fi
done;
# Keep or dismiss the framework changes
# ------------
if [ "$keep" = true ] ; then
echo "---- KEEP $framework ----"
else
git checkout "$framework" --force
echo "Undo $framework"
fi
done;
echo "\n🐌 🐝 🐸"
# Make string comparison case sensitive
shopt -u nocaseglob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment