cocoaPods安装步骤

1.升级Ruby环境

sudo gem update –system


2.安装CocoaPods时我们要访问cocoapods.org,用淘宝的RubyGems镜像来代替官方版本,执行以下命令:

gem sources --remove https://rubygems.org/

//等有反应之后再敲入以下命令

gem sources -ahttps://ruby.taobao.org/

 

3.为了验证你的Ruby镜像是并且仅是taobao,可以用以下命令查看:

gem sources –l

只有在终端中出现下面文字才表明你上面的命令是成功的:

<span style="font-family:SimSun;font-size:14px;">*** CURRENT SOURCES ***</span>
<span style="font-family:SimSun;font-size:14px;"> </span>
<span style="font-family:SimSun;font-size:14px;">http://ruby.taobao.org/</span>
 

4.安装Cocoapods,在终端输入命令

sudo gem install cocoa pods

#设置

pod setup      //这步需要较长时间,可以用命令du -sh *查看进度


5.在项目中创建cocoapod

vim Podfile

Podfile的内容:

最低支持的 iOS 版本

platform :ios, '8.0'

# Swift 项目需要将框架转换为 frameworks 才能使用

use_frameworks!

#添加第三方库的target

target “test” do

框架列表

pod 'AFNetworking’, ‘3.1.0’

#记得要加上end

end


之后就可以利用CocoPods下载AFNetworking类库了。还是在终端中的当前项目目录下,运行以下命令:

#安装

pod install


6.pod命令汇总

# 第一次使用安装框架

$ pod install 


# 今后升级、添加、删除框架,或者框架不好用

$ pod update


# 搜索框架

$ pod search XXX


# 在项目文件夹下创建默认的 Podfile

$ pod init


7.安装中遇到的问题

安装cocoa pods时,在终端执行pod search第三方框架时出错:[!] Unable to find a pod with name, author, summary, ordescriptionmatching `AFNetworking`

 

解决方案:执行rm ~/Library/Caches/CocoaPods/search_index.json

         然后再执行pod search第三方框架

 

执行pod install时报错:[!] The dependency `AFNetworking` is not used in any concrete target.

 

Pod file文件内容:#最低支持的 iOS 版本

platform :ios, '8.0'

# Swift项目需要将框架转换为 frameworks才能使用

use_frameworks!

#框架列表

pod 'AFNetworking’, ‘3.1.0’

解决方案:Podfile文件内容中加上:target "RWTFlickrSearch" do,记得在最后要加上end

 

修改后的Podfile#最低支持的 iOS 版本

platform :ios, '8.0'

# Swift项目需要将框架转换为 frameworks才能使用

use_frameworks!

 

#添加第三方库的target

target “test” do        // test是项目的target

 

#框架列表

pod 'AFNetworking’, ‘3.1.0’

 

#记得要加上end

end



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值