2017版cocoapods安装及使用和注意事项
2017-06-26 22:39
309 查看
A.安装ruby
a 查看ruby版本
ruby -v
b.如果版本低升级。
1.先安装rvm。Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)。
curl -L https://get.rvm.io | bash -s stable
2.载入rvm环境
source ~/.rvm/scripts/rvm
3.用rvm 安装ruby环境
rvm install 2.3.0
4.设置为默认版本
rvm use
2.2.4 --default
5.安装rails
gem install rails
补充命令
如果要删除ruby版本,先用list命令。
▪ rvm list 查看已安装ruby
▪ rvm list known 列出ruby可安装版本信息
▪ rvm remove 2.2.2 卸载一个已安装的ruby版本
▪ gem source 查看已有源
▪ gem sources -a
http://ruby.taobao.org把源切换至淘宝镜像服务器
B.安装CocoaPods
a.检查ruby源
gem sources -l
推荐官方的:https://gems.ruby-china.org https://ruby.taobao.org/ 淘宝源 http://rubygems-china.oss.aliyuncs.com 阿里云源
b.添加ruby镜像源
gem sources -a https://gems.ruby-china.org
c.安装
sudo gem install cocoapods
d.安装结束后,执行命令
pod setup
C.使用CocoaPods
a.新建一个项目,名字CocoaPodsTest
b.终端中,cd到项目总目录(注意:包含CocoaPodsTest文件夹、CocoaPodsTest.xcodeproj的那个总目录)
c.建立Podfile(配置文件)
1.终端输入 vim Podfile
2.键盘输入 i,进入编辑模式,
3.输入最新的platform和最新的第三方的名称和版本.参考如下格式
platform :ios, '9.0'
target 'JinXinHospital' do
pod 'AFNetworking','~> 3.1.0'
end
4.按Esc,并且输入“
:”号进入vim命令模式,然后在冒号后边输入wq
注意:键盘输入 :后,才能输入wq。回车后发现PodTest项目总目录中多个Podfile文件
5.输入 pod install,
6.安装好各个第三方之后,打开后缀名为.xcworkspace的文件,即可使用
d.注意:
1)项目存在多个Target的时候,需要配置Podfile文件来支持新增加的Target,否则只支持项目默认建立时生成的Target:
link_with 'Test', 'Second'
platform :ios
pod 'AFNetworking', '~> 2.0'
2)项目有不同依赖库时
platform :ios
target :'Test' do
pod 'Reachability'
pod 'SBJson'
pod 'AFNetworking'
end
target :'Second' do
pod 'OpenUDID'
end
参考链接博客:http://blog.csdn.net/daiyelang/article/details/51766916
D.使用CocoaPod问题
a.fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead()
遇到这种问题的话,可以手动去克隆一份到repos目录下面。
步骤
1.通过finder的前往文件夹进行查看 ~/.cocoapods/repos
2.通过终端,进入到 ~/.cocoapods/repos
3.然后通过 git clone
https://github.com/CocoaPods/Specs.git
还有其他问题的话,先看看是不是rubygem镜像源是不是被墙了,可以切换镜像源。
甚至,如果最终实在没办法,找到一个安装好了cocoapods的Mac电脑,到他的~/.cocoapods/repos目录下面拷贝出master文件到自己的Mac上的相应位置。
参考链接:http://www.jianshu.com/p/b64b4fd08d3c
b.error: RPC failed; curl 18 transfer closed with outstanding read data remaining
参考链接: http://blog.csdn.net/wangyanchang21/article/details/51437934 可能是因为有多个Xcode:
xcode-select —print-path 查看Xcode安装路径
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
c.unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806
网络不好的原因
d.error: RPC failed; curl 56 SSLRead() return error -36 | 547.00 KiB/s
参考链接: http://blog.csdn.net/wm9028/article/details/51840759
e.Invalid `Podfile` file: undefined method `Pod' for #<Pod::Podfile:0x007fdb9530cd70>
cocoapod需要更新
运行 sudo gem install cocoapods 进行更新 cocoapods
更新完后再运行 pod update
f.Unable to find a pod with name, author, summary, or description matching `AFNetworking`
先删除:rm -rf ~/.cocoapods
再pod setup
a 查看ruby版本
ruby -v
b.如果版本低升级。
1.先安装rvm。Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)。
curl -L https://get.rvm.io | bash -s stable
2.载入rvm环境
source ~/.rvm/scripts/rvm
3.用rvm 安装ruby环境
rvm install 2.3.0
4.设置为默认版本
rvm use
2.2.4 --default
5.安装rails
gem install rails
补充命令
如果要删除ruby版本,先用list命令。
▪ rvm list 查看已安装ruby
▪ rvm list known 列出ruby可安装版本信息
▪ rvm remove 2.2.2 卸载一个已安装的ruby版本
▪ gem source 查看已有源
▪ gem sources -a
http://ruby.taobao.org把源切换至淘宝镜像服务器
B.安装CocoaPods
a.检查ruby源
gem sources -l
推荐官方的:https://gems.ruby-china.org https://ruby.taobao.org/ 淘宝源 http://rubygems-china.oss.aliyuncs.com 阿里云源
b.添加ruby镜像源
gem sources -a https://gems.ruby-china.org
c.安装
sudo gem install cocoapods
d.安装结束后,执行命令
pod setup
C.使用CocoaPods
a.新建一个项目,名字CocoaPodsTest
b.终端中,cd到项目总目录(注意:包含CocoaPodsTest文件夹、CocoaPodsTest.xcodeproj的那个总目录)
c.建立Podfile(配置文件)
1.终端输入 vim Podfile
2.键盘输入 i,进入编辑模式,
3.输入最新的platform和最新的第三方的名称和版本.参考如下格式
platform :ios, '9.0'
target 'JinXinHospital' do
pod 'AFNetworking','~> 3.1.0'
end
4.按Esc,并且输入“
:”号进入vim命令模式,然后在冒号后边输入wq
注意:键盘输入 :后,才能输入wq。回车后发现PodTest项目总目录中多个Podfile文件
5.输入 pod install,
6.安装好各个第三方之后,打开后缀名为.xcworkspace的文件,即可使用
d.注意:
1)项目存在多个Target的时候,需要配置Podfile文件来支持新增加的Target,否则只支持项目默认建立时生成的Target:
link_with 'Test', 'Second'
platform :ios
pod 'AFNetworking', '~> 2.0'
2)项目有不同依赖库时
platform :ios
target :'Test' do
pod 'Reachability'
pod 'SBJson'
pod 'AFNetworking'
end
target :'Second' do
pod 'OpenUDID'
end
参考链接博客:http://blog.csdn.net/daiyelang/article/details/51766916
D.使用CocoaPod问题
a.fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead()
遇到这种问题的话,可以手动去克隆一份到repos目录下面。
步骤
1.通过finder的前往文件夹进行查看 ~/.cocoapods/repos
2.通过终端,进入到 ~/.cocoapods/repos
3.然后通过 git clone
https://github.com/CocoaPods/Specs.git
还有其他问题的话,先看看是不是rubygem镜像源是不是被墙了,可以切换镜像源。
甚至,如果最终实在没办法,找到一个安装好了cocoapods的Mac电脑,到他的~/.cocoapods/repos目录下面拷贝出master文件到自己的Mac上的相应位置。
参考链接:http://www.jianshu.com/p/b64b4fd08d3c
b.error: RPC failed; curl 18 transfer closed with outstanding read data remaining
参考链接: http://blog.csdn.net/wangyanchang21/article/details/51437934 可能是因为有多个Xcode:
xcode-select —print-path 查看Xcode安装路径
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
c.unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806
网络不好的原因
d.error: RPC failed; curl 56 SSLRead() return error -36 | 547.00 KiB/s
参考链接: http://blog.csdn.net/wm9028/article/details/51840759
e.Invalid `Podfile` file: undefined method `Pod' for #<Pod::Podfile:0x007fdb9530cd70>
cocoapod需要更新
运行 sudo gem install cocoapods 进行更新 cocoapods
更新完后再运行 pod update
f.Unable to find a pod with name, author, summary, or description matching `AFNetworking`
先删除:rm -rf ~/.cocoapods
再pod setup
相关文章推荐
- VSS安装使用注意事项大全
- 在服务器上安装、使用MySQL的注意事项
- 在linux或unix服务器上安装、使用MySQL的注意事项
- android虚拟机emulator应用安装--使用adb install安装步骤和注意事项
- yii安装使用注意事项
- 在服务器上安装、使用的注意事项(1)
- 安装使用HookLogger的注意事项
- PRTG流量监控基本安装和使用方法及注意事项
- 安装和使用MySQL注意事项
- boost循序渐进1: boost的安装及注意使用注意事项
- 服务器上安装、使用MySQL注意事项(2)
- 免安装Oracle客户端使用PL/SQL连接Linux Oracle 注意事项
- 在AIX操作系统上安装使用VIM的注意事项
- PRTG流量监控基本安装和使用方法及注意事项
- solaris工具的安装,使用和注意事项(gcc,gzip,make,nmap,wget)
- 在服务器上安装、使用MySQL的注意事项(1)
- OPENCV的在LINUX下的安装使用注意事项
- VMWare 6.5 安装Gentoo时使用SCSI硬盘注意事项
- django 数据库增强工具 south 的安装使用和注意事项。。。
- ubuntu12.04 安装openstack注意事项,使用cinder