iOS开发日常-Carthage秘籍之【安装、使用】

基本概念

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库依赖完成?.

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值