iOS Dev Nugget 127 Dependency Management for 3rd Party Code: Carthage


Need to run a code review on your codebase? Hire me

In #126, I mentioned CocoaPods. There is a newer alternative tool for 3rd party code dependency management called Carthage.

The developers described it as:

"CocoaPods (by default) automatically creates and updates an Xcode workspace for your application and all dependencies. Carthage builds framework binaries using xcodebuild, but leaves the responsibility of integrating them up to the user. CocoaPods’ approach is easier to use, while Carthage’s is flexible and unintrusive."

There are a few key differences between Carthage and CocoaPods:

  1. Carthage only supports dynamic frameworks. So the third party code must have targets to build dynamic frameworks. It also means that your project has to support iOS 8 and newer only.
  2. Carthage doesn't have a centralized ecosystem like CocoaPods, so there is no central repository or list of 3rd party modules/repositories that are supported. You are on your own to find the code that you want and create a target to build a dynamic framework if it doesn't already support that.
  3. Carthage is less intrusive. You get to use and maintain your own .xcodeproj.

Here's how to use it:

  1. Install Carthage:

    Download and run Carthage.pkg or use homebrew: brew install carthage

  2. Create a Cartfile that lists the frameworks you want to use:

    github "ReactiveCocoa/ReactiveCocoa" >= 2.3.1 github "jspahrsummers/libextobjc" == 0.4.1

  3. Run:

    carthage update

  4. Drag and drop the built frameworks in Carthage/Checkouts into your Xcode project.

You then iterate through steps 2-4 during development.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues