Cato makes it easy to manage your Xcode project's dependencies using Rake (a Make-like dependency management tool implemented in Ruby).
Cato unobtrusively downloads, builds, and copies static libraries and frameworks into the places where Xcode expects to find them.
Cato began as a set of Ruby scripts designed to manage dependencies in the LogCheck mobile app. Primarily for the sake of tidiness, I decided to factor it out into this gem. Maybe someone else will find it useful for their project. Who knows?
In a nutshell:
-
Create a
Rakefilethat includesrequire 'cato/tasks'and describes your dependencies. -
In Xcode, add an "External Build System" target that runs
rake cato:install --trace. -
Add dependencies to your Xcode project (see below).
The above will work only if you install the cato gem ahead of time;
if you want to make life easier on the developers using the project,
you can write a shell script that will install the gem if needed.
-
Add a
PackageTaskto yourRakefilethat describes where to download it from. Add one or morexcodebuilddeclarations if building from source, and add one or morestatic_libraryand/orframeworkdeclarations. -
In Xcode, change the active scheme destination to "Generic iOS Device" (instead of a simulator). This shouldn't matter, but it does.
-
Build the project in Xcode, which will run
rake cato:install. Rake will put the needed files into Xcode'sBUILT_PRODUCTS_DIR. It's OK if the build fails, as long as therakeexecution succeeded. -
Navigate to the target's "Build Phases" tab and the "Link Binary With Libraries" section. IMPORTANT: When adding a static library or framework, navigate through the
Cato/XcodeProductsfolder link and select the item from there. -
Within the "Build Phases" tab, ctrl-click the new library or framework and select "Reveal in Project Navigator"; from there, ctrl-click again and select "Show File Inspector".
-
In the File Inspector, change the Location to "Relative to Build Products". If everything is correct, the filename below the pop-up menu will appear without any leading path information. (For example, you should see
libFooBar.aand not../Debug-iphonesimulator/libFooBar.a.) -
Build again and everything should be working!
-
It would be helpful to pick some public projects using Carthage or CocoaPods and "Cato-ize" them, to test how well this thing works apart from the LogCheck app.
-
I probably need to explain how Cato compares to CocoaPods and Carthage, in a polite way. :-)