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

本文介绍Carthage,一种用于iOS应用的简单框架管理工具。Carthage允许开发者保留项目结构控制,通过创建Cartfile列出依赖,运行carthage update进行更新。文章详细解释了从安装Carthage到在Xcode中使用框架的步骤。

基本概念

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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值