Skip to content

Instantly share code, notes, and snippets.

@algal
Created December 6, 2016 16:36
Show Gist options
  • Save algal/90095cdc1d6d564b33d783295cfe858a to your computer and use it in GitHub Desktop.
Save algal/90095cdc1d6d564b33d783295cfe858a to your computer and use it in GitHub Desktop.
carthage as a version-aware downloader
#!/bin/sh
command -v carthage >/dev/null 2>&1 || { echo >&2 "I require carthage but it's not installed. Aborting."; exit 1; }
carthage update --no-build
# A policy proposal:
#
# We use the "carthage" tool only to download the source code of
# third-party libraries that we depend on.
#
# We then manually add those projects into our workspace.
#
# So if one of our projects needs to use one of thse third-party
# libraries, then it can simply depend on that other project's build
# products, since they are in the same workspace.
#
# In other words, a "Carthage-managed dependency" is simply a
# third-party library, which is downloaded by Carthage, but
# integrated into the workspace by us.
#
#
# Q: How to declare a new Carthage-managed dependency?
# A: Add it to ./Cartfile
#
# Q: How to download all the Carthage-managed dependencies?
# A: Run this script.
#
# Q: Will it change any of the existing Carthage-managed dependencies?
# A: It may restore some build schemes which were deleted just for the
# sake of convenience, but this won't break anything, and you can delete
# them again from the Manage Schemes dialog, if you want to.
#
# Q: How to integrate a Carthage-managed dependency to the workspace?
# A: If the project is called Foo, for instance, find its xcodeproj
# file in Carthage/Checkouts/Foo/, and drag that file into the
# workspace. Put it in the "Carthage-managed project srcs" group
# folder, just so other users know that it is a Carthage-managed dependency.
#
# Q: How do I install carthage?
# A: $ brew install carthage
#
# Q: How do I make my own library or application, which is already
# within the workspace, depend on a Carthage-managed dependency which
# defines a framework?
#
# A: First, go Builds Phases / Linked Library, and add the
# framework. Second, if you are adding this as a dependency for an
# application, then additionally go Build Phases / Embed Frameworks, and
# add the framework there as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment