基本概念
Carthage is intended to be the simplest way to add frameworks to your Cocoa application.Carthage builds your dependencies and provides you with binary framworks, but you retain full control over your project structure and setup. Carthage does not automatically modify your project files or your build settings.
Carthage安装
You can use Homebrew and install the carthage tool on your system simply by running brew update and brew install carthage.
brew update
brew install carthage
Carthage使用
1. Create a Cartfile in the same directory where your .xcodeproj or .xcworkspace is.
2. List the desired dependencies in the Cartfile,for example:
github "Alamofire/Alamofire" ~> 4.7.2
3. Run carthage update --platform iOS
carthage update --platform iOS
4. A Cartfile.resolved file and a Carthage directory will appear in the same directory where your .xcodeproj or .xcworkspace is.
5. Drag the built .framework binaries from Carthage/Build/iOS into your application’s Xcode project.
6. On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
Add the paths to the frameworks you want to use under “Input Files". For example:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
Add the paths to the copied frameworks to the “Output Files”. For example:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework
7. Alamofire库依赖完成?.