Skip to content

Instantly share code, notes, and snippets.

@DerekK19
Last active June 19, 2016 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerekK19/4aebcc3a370295c6686f65700385629e to your computer and use it in GitHub Desktop.
Save DerekK19/4aebcc3a370295c6686f65700385629e to your computer and use it in GitHub Desktop.
#!/bin/sh
# Script used in XCode build phase to bring Carthage dependencies up to date
# Will check if the Cartfile is newer than the Cartfile.resolved, and if so
# Will bring the Carthage checkouts up to date
# If the checkouts are newer than the build
# Will bring the build up to date
#
# Derek Knight
# Jun 2016
if [ -z "$CONFIGURATION" ]; then
CONFIGURATION="Release"
fi
if [ -z "$PLATFORM" ]; then
PLATFORM="iOS"
fi
if [ "Cartfile" -nt "Cartfile.resolved" ]; then
echo "Cartfile is newer than source, removing source"
rm -rf Carthage/Checkouts
fi
if ! [ -d "Carthage/Checkouts" ]; then
echo "Source doesn't exist, checking out"
env -i /usr/local/bin/carthage update --no-build --platform $PLATFORM --configuration $CONFIGURATION $*
rm -rf Carthage/Build/$PLATFORM
fi
if [ -d "Carthage/Build/$PLATFORM" ]; then
echo "$PLATFORM Build exists"
else
echo "Build doesn't exist, building"
env -i /usr/local/bin/carthage build --platform $PLATFORM --configuration $CONFIGURATION $*
fi
@DerekK19
Copy link
Author

I save this as /usr/local/bin/carthage-xcode, then my Xcode run Script task "Update/Build Carthage Dependencies" is just one line:

/usr/local/bin/carthage-xcode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment