Carthage https://github.com/Carthage/Carthage 轻耦合的Cocoa依赖管理工具,它与CocoaPods不同的是,它使用xcodebuild来编译依赖项目为.framework, 然后手动将.framework添加到自己的项目里即可,而不会修改我们的项目文件和编译设置。 注意:Carthage只支持动态框架,必须iOS8以上才行。 安装: $ brew update $ brew install carthage 使用: 1. 创建一个Cartfile文件,将需要的框架列在里面。 每个框架一行文字就可以了,用git开头或者github开头,格式如: github "Alamofire/Alamofire" ~> 3.0 框架开发者会提供Carthage方式的语句。 2. 运行命令carthage update,会自动生成Cartfile.resolved,里面包含了依赖文件的具体版本,如: github "Alamofire/Alamofire" "3.1.4" 生成Checkouts文件夹,包含了依赖文件的源代码。 生成Build文件夹,包含了各个平台编译后的.framework文件。 3. 手动将.framework文件添加/引入到自己的项目里。 把.framework文件拖拽到应用程序的Target - General设置中的“Embedded Binaries”里。 非应用程序Target拖拽到“Link Binaries With Libraries”里。 例子:以Alamofire依赖库为例 $ cd ~/Developer $ md carthage $ cd carthage // 建立一个carthage目录,用来Cartfile管理依赖库 $ vi Cartfile // 创建Carfile文件,添加Alamofire依赖库 github "Alamofire/Alamofire" ~> 3.0 $ carthage update // 签出Cartfile中描述的依赖项并且编译 *** Cloning Alamofire *** Checking out Alamofire at "3.1.4" *** xcodebuild output can be found in /var/folders/0_/5g011j892wsd5rtmpl34z8zw0000gn/T/carthage-xcodebuild.Ddv46y.log *** Building scheme "Alamofire iOS" in Alamofire.xcworkspace *** Building scheme "Alamofire tvOS" in Alamofire.xcworkspace *** Building scheme "Alamofire OSX" in Alamofire.xcworkspace *** Building scheme "Alamofire watchOS" in Alamofire.xcworkspace $ open . // 用Finder打开carthage目录 然后用Xcode打开需要引入Alamofire库的项目,假设名字叫SwiftDemo的iOS项目,选择SwiftDemo项目, 选择TARGETS中的SwiftDemo,选择General设置,将carthage编译文件CartfileBuildiOSAlamofire.framework 拖拽到General设置的“Embedded Binaries”中。 ------ 更多用法: https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile