Step 1: Install Carthage on you mac
brew install Carthage
Step 2: Set Cartfile file for your project
Under your project root directory,
vim Cartfile. For example, if I want to install the GCXTrustPolicy for my project, I just need to have the following in the Cartfile:
Sometimes you can see:
github "ReactiveCocoa/ReactiveCocoa" >= 2.3.1
- == 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
Step 3: Install libraries for your project
carthage update --platform iOS
At this stage, it will create the following folders and directories:
Cartfile.resolved：This file has the identical content of file
Build：contains the binary frameworks and debug information for each dependency (whether built from scratch or downloaded).
Checkouts：contains your dependencies’ source code.
Step 4 (Optional): Update libraries
If you want to update libs, run with any of the following cmd:
carthage update SVProgressHUD --platform iOS carthage update Dollar --platform iOS
--platform iOScmd 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
Step 5: Add built framework into the project
Doing by Select Target -> General -> Add Frameworks
Run Script in the
Build Phases (see the following image):
Under Input Files (I installed two libs), see the following image:
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:
Congrats~ Now you can use the libs now.