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加目标。