安装CocoaPods

1、打开终端输入命令:sudo gem update --system

终端提示:

WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.


To proceed, enter your password, or type Ctrl-C to abort.


Password:(在这里输入本机的密码,需要注意的是你输入的时候并不会有星星提示,看起来没反应,你不用管直接输入完成后Enter就可以了)


2、等待一下屏幕出现

Updating rubygems-update

Fetching: rubygems-update-2.6.5.gem (100%)

Successfully installed rubygems-update-2.6.5

Parsing documentation for rubygems-update-2.6.5

Installing ri documentation for rubygems-update-2.6.5

Installing darkfish documentation for rubygems-update-2.6.5

Installing RubyGems 2.6.5

RubyGems 2.6.5 installed

Parsing documentation for rubygems-2.6.5

Installing ri documentation for rubygems-2.6.5


=== 2.6.5 / 2016-06-21

。。。。

3、这样sudo命令就安装好了,接下来我们安装CocoaPods,在终端输入:

sudo gem install cocoa pods

然后输入密码,和之前一样。你需要等一一下,在安装过程如果遇到冲突或者其他情况中会遇到Y/N的选项,一般情况下选Y


4、遇到错误:

ERROR:  While executing gem ... (Errno::EPERM)

        Operation not permitted - /usr/bin/fuzzy_match

解决方案:sudo gem install -n /usr/local/bin cocoapods

成功解决

5、然后输入命令:pod setup 

过一段时间后报:

Setting up CocoaPods master repo

Setup completed

到这里,你已经成功安装了CocoaPods!

6、给自己的项目加pods,首先关闭Xcode进入到项目文件夹下

命令:cd /Users/AhaoPlus/Downloads/TeamTalk-master/ios

命令:pod install

这条命令会在项目文件夹下生成一个Podfile的文件

命令:open -a Xcode Podfile

使用Xcode打开这个文件进行编辑:

platform:ios, '7.0'


target "TeamTalk" do


pod 'FMDB', '~> 2.3'

pod 'SDWebImage', '~> 3.6'

pod 'AFNetworking', '~> 2.3.0'

end

这个脚本自己体会一下很好懂的。到此为止我们已经把项目添加了cocoaPods



另外:有时候我们从Github 上下载项目打开后运行报错

iOS 'The sandbox is not sync with the Podfile.lock'问题解决参考http://www.thinksaas.cn/topics/0/351/351314.html

问题描述:

github下载的Demo,很多时候使用到CocoaPods,有的时候因为依赖关系或者版本问题不能编译运行。出现例如The sandbox is not sync with the Podfile.lock问题时候,如下所示

diff: /../Podfile.lock: No such file or directory 
diff: Manifest.lock: No such file or directory 
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.` 

解决方案

关闭当前的工作空间,删除掉文件夹中的workspace,然后重新pod install,install完成之后,通过workspace打开工作空间,clean+build即可,如下所示

rm -rf MyProject.xcworkspace 
pod install 

在pod install之前,请确保已经执行pod setup命令。




在项目文件夹下执行:pod install命令报错:

Re-creating CocoaPods due to major version update.

Analyzing dependencies

[!] The dependency `FMDB (~> 2.3)` is not used in any concrete target.

The dependency `SDWebImage (~> 3.6)` is not used in any concrete target.


解决办法:

将Pod file文件用Xcode打开

将文件中

platform:ios, '7.0'

pod 'FMDB', '~> 2.3'

pod 'SDWebImage', '~> 3.6'

改为

platform:ios, '7.0'

target "TeamTalk" do

pod 'FMDB', '~> 2.3'

pod 'SDWebImage', '~> 3.6'

end

即给Podfile加目标。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值