chevron-up bell reply instagram twitter2 feed3 finder search-25px-p0

A Quick Start on Carthage

2016-07-19

0x00: Install Carthage on you mac:

brew install Carthage

0x01: Under your project root directory, vim Cartfile:

Notice:

  • == 1.0 means using version 1.0
  • >= 1.0 means using version 1.0 or higher
  • ~> 1.0 means using version 1.0 but lower than version 2.0, i.e. 1.2

0x02: In your project root directory, run:

carthage update --platform iOS

At this stage, it will create:

Cartfile.resolved: This file has the identical content of file Cartfile.

Build: contains the binary frameworks and debug information for each dependency (whether built from scratch or downloaded).

Checkouts: contains your dependencies’ source code.

If you want to update libs, run with any of the following cmd:

carthage update SVProgressHUD --platform iOS
carthage update Dollar --platform iOS

Notice:

  • --platform iOS cmd parameter is optional which build binary framework just for iOS. If it is not specified, it will create binary framework for all platforms.
  • Better to gitignore build, Checkouts

0x03: Add built framework into the project:


0x04: Add Run Script in the Build Phases:

/usr/local/bin/carthage copy-frameworks

Under Input Files:

$(SRCROOT)/Carthage/Build/iOS/SVProgressHUD.framework
$(SRCROOT)/Carthage/Build/iOS/Dollar.framework

As it is shown in the following image:

Technically, build phase is not quite necessary to run the project, but it will avoid the awkward situation that being rejected when submitting to App Store for review.

Use the following cmd to remove those frameworks project information:

carthage copy-frameworks

In your project, you can import

import SVProgressHUD
import Dollar

Reference

https://github.com/Carthage/Carthage

arkilis

Make Your Comments