cocaopods安装 升级及配置Podfile文件

命令行更新(安装)

$ sudo gem update --system // 先更新gem,国内需要切换源
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
\*\*\* CURRENT SOURCES \*\*\*
https://ruby.taobao.org/
$ sudo gem install cocoapods // 安装cocoapods
$ pod setup
补充:安装的过程中遇到错误:ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod
解决方案:sudo gem install -n /usr/local/bin cocoapods 替换掉sudo gem install cocoapods

stackoverflow中的回答

查看版本

$ pod --version

安装第三方框架

//Podfile文件配置(OC)
target 'YourAppName' do
    pod '三方框架' '~> 版本号'
end
//终端执行
pod install

注意:编辑Podfile文件不要直接用文本编辑器,否则会报如下错误(可以直接用xcode打开进行编辑)

[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

使用cocoapods导入第三方类库后头文件没有代码提示?

解决办法: 选择Target -> Build Settings 菜单,找到\”User Header Search Paths\”设置项,新增一个值"${SRCROOT}",并且选择\”Recursive\”
cocaopods安装 升级及配置Podfile文件_第1张图片
Snip20160519_1.png

在使用pod install安装第三方库的时候可能会卡在Updating local specs repositories

//解决办法
把pod install 换成 pod install --verbose --no-repo-update

以上是使用cocoapod遇到的问题及解决方案的一个小总结
欢迎补充

你可能感兴趣的:(cocaopods安装 升级及配置Podfile文件)