Carthage Tutorial: Getting Started

Carthage Tutorial: Getting Started

Learn how to use Carthage to manage your project’s dependencies.

[…]

It’s widely used in the iOS community, and even Google uses it to distribute their various iOS SDKs.

Alongside Swift 3.0, Apple has released its own tool called Swift Package Manager to share and distribute packages in Swift 3.0 and above. Apple defines it as:

The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

While CocoaPods and Swift Package Manager are awesome, there are other options. Carthage is one such alternative; it’s a ruthlessly simple dependency manager for macOS and iOS, created by a group of developers from Github.

It was the first dependency manager to work with Swift; in fact, Carthage itself is written in Swift! It exclusively uses dynamic frameworks instead of static libraries – this is the only way to distribute Swift binaries that are supported by iOS 8 and up.

[…]

Note: This Carthage tutorial assumes that you have basic familiarity with iOS and Swift, that you’re familiar with Xcode and working with the command line.

[…]

So how exactly is Carthage different from CocoaPods, and why would you use anything besides the most popular dependency manager for iOS?

[…]

How about the differences between Carthage and Swift Package Manager?

[…]

And then open the file up in Xcode for editing:

[…]

Be sure to replace path to Xcode 9 beta with your machine’s specific path to Xcode 9.

[…]

The --platform iOS option ensures that frameworks are only built for iOS. If you don’t specify a platform, then by default Carthage will build frameworks for all platforms (often both Mac and iOS) supported by the library.

[…]