Topics

#11: Carthage 🗿

Topics

Carthage is a new way to integrate third-party libraries in your apps. One way to think of it is as a simpler alternative to CocoaPods. It’s a dependency manager distilled down to just about it’s simplest possible form.

One of the notable differences between Carthage and CocoaPods is that Carthage doesn’t require an Xcode Workspace to be created or "automagically" managed. It can be installed via a downloadable installer or with a simple brew install carthage.

Create a Cartfile, which is just a plain text file filled with lines like the ones below. Each of these tell Carthage about a library you’d like to use in your app.

github 'Alamofire/Alamofire'
github 'Hearst-DD/ObjectMapper'
github 'Haneke/HanekeSwift'

Then, simply run carthage update. At which point Carthage will go out and download and build all the libraries you asked for.

Note: Similar to CocoaPods’ pod install, you’ll also need to run carthage update anytime you change or update your Cartfile.

Where things begin to feel different from CocoaPods is that the next step is to manually drag and drop the frameworks Carthage built when you ran carthage update into the Linked Frameworks and Libraries of your Xcode target’s General settings panel.

Finally, import the libraries in your code:

import Alamofire
import ObjectMapper
import Haneke

More info about Carthage can be found at git.io/carthage