Automate github downloads and xcodebuild
Scipio scripts the download & build of Cocoa frameworks. Scipio’s offered as an alternative to Carthage and CocoaPods. Scipio uses the same sort of Cartfiles as Carthage and the basic workflow is the same:
Carthago delenda est!
CocoaPods is the grandfather of dependency management for Cocoa. Carthage was created to be a decentralized alternative. Carthage was written in Swift, and not only Swift, but some of the more experimental bits of Swift.
I love Swift. I love the idea of Carthage, so I wrote Scipio, in Python. Python isn’t going to get experimental again any time soon, and decoupling the language of this tool from the still rapidly changing language it’s used to build means for (I hope) a lot less heartache.
Scipio’s a Python script, it should run in Python 2 or 3, and on a Mac you already have that installed. You’ll also obviously need Xcode. To install Scipio, open terminal and type:
pip install scipio
In the folder you want your frameworks built, create a file called ‘Cartfile’ with lines in the format:
github "Alamofire/AlamofireImage" ~>2.1
That’s more or less the same format Carthage uses, though there are some differences. The version comparators supported are < <= = == >= > ~ and ~>
= and == are synonymous, but ~ and ~> aren’t (see below for the differences to Carthage’s Cartfiles).
Then cd to the folder and run Scipio from the terminal
Scipio will download the best match it can find from the tagged versions of the repository on Github and build the project/workspace. It doesn’t have to be a framework, but building frameworks is the main use case. If the project has a Cartfile in it that framework will be downloaded and built first (and so on recursively).
You can pass along arguments at the command line to modify scipio or xcodebuild’s behavior. Type scipio -h for the current list. If a target/scheme etc exists in the project or workspace it will be used. If it doesn’t exist, or if no arguments are supplied then the defaults set up by a framework’s authors’ are used.
|-h, –help||show this help message and exit|
|-down||download & unzip but don’t build|
|-plistb||change all plist build numbers to this string|
|-plistv||change all plist version numbers to this string|
|-project||xcodebuild: project name|
|-workspace||xcodebuild: workspace name|
|-configuration||xcodebuild: configuration name|
|-scheme||xcodebuild: scheme name|
|-sdk||xcodebuild: sdk full path or canonical name|
|-target||xcodebuild: project target name|
|-verbose||xcodebuild will let you know, a lot|
|-v, –version||show program’s version number and exit|
I’m not trying especially hard to support some of Carthage’s design choices – OGDL anyone? – but I’m not trying to become incompatible either.
Using Node, ~1.2 and ~1.2.0 for example both don’t match 1.3. In Ruby ~>1.2.0 doesn’t match 1.3, but ~>1.2 does. Scipio respects both ~ and ~>. Carthage doesn’t. Carthage uses Ruby’s ~> to mean Node’s ~.
== and = can both be used to mean equals.
So far named tags aren’t supported in place of version constraints (but I plan to).
Others gits are introduced with the word git in Carthage Cartfiles, in Scipio that’s optional. (The other git functionality is completely untested so that may change.)
You can change the build and version numbers of all the projects you’re building in one Cartfile to be the same, using the optional -plistb and -plistv flags. For a brief moment iTunes Connect seems to have required this, possibly in error. This doesn’t work with download & unzip only, only for builds. As a philosophical aside, this is a little CocoaPods-like for my taste. Use is eg
scipio -plistv 42.0.0
Carthage and Cocoapods, obviously. Miguel Hermoso for the picture of Scipio looking existentially disappointed.