[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Carthage: GitHub's Dependency Manager for Xcode Projects

Carthage: GitHub's Dependency Manager for Xcode Projects

Leia em PortuguÃas

Apr 28, 2015 1 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

Carthage is a dependency manager for Objective-C and Swift projects aims to be "ruthlessy simple," says its author Justin Spahr-Summers. Carthage has been developed at GitHub and its philosophy is "delegating tasks to Xcode and Git" as much as possible so developers can use the tools they "are already familiar with."

Dependency management is key in order to be able to effectively reuse code through libraries or frameworks. As Spahr-Summers recounts, before Carthage several ways to distribute libraries were available for Cocoa/CocoaTouch projects:

  • Manually copied source files, which does not support any kind of versioning and thus is prone to conflits.
  • Subversion externals, Git submodules, or Git subtrees, each of which has its own flaws, says Spahr-Summers. In particular, Git submodules tend to work pretty well until two or more of your project's dependencies have a common dependency.
  • CocoaPods, the de-facto standard for dependency management with Cocoa. Unfortunately, CocoaPods has a few drawbacks, according to Spahr-Summers, such as the requirement to add a Pod specs file to all projects and to upload it to a central repository. The biggest CocoaPods' drawback, though, is how it takes "control of the project set up process," by creating an Xcode workspace for you and adding its Pod projects to it.

Thus, Carthage was born with the goal of being "a simple coordinator between Git and XCode" that would "pick compatible versions for all dependencies, check out dependencies with Git, and then build frameworks with Xcode."

Using Carthage requires the developer to carry through a series of steps:

  1. The first step in order to be able to use Carthage is to install it, either through a prepackaged binary installer, or using Homebrew. This step is only required once.

  2. Then, all required GitHub dependencies can be specified in a Cartfile, e.g.

    github "Mantle/Mantle" ~> 1.5
    github "ReactiveCocoa/ReactiveCocoa" >= 2.4.7
    github "ReactiveCocoa/ReactiveCocoaLayout" == 0.5.2
    
  3. Once the Cart file has been created, running carthage update will recursively download and build all dependencies.

  4. Finally, all frameworks that Carthage built can be added to an Xcode project. For iOS, an additional required step is to strip architectures since the App Store does not allow framework binaries that include X86_64 binaries.

One limitation of Carthage comes from it only supporting frameworks, so it is not possible to use it for apps targeting iOS version prior to iOS 8.

Rate this Article

Adoption
Style

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /