cocoaPods

cocoaPods是啥?

简单的说就是个管理第三方开源库的玩意,比如MJRefresh之类的。想要啥,只要在podfile文件中加一行就行,然后pod install一下,第三方库就加到工程中了,很简单,现在来安装吧。

安装安装前先检查下Ruby有没有安装这样表示安装好了。

在终端输入以下命令:

$ sudo gem install -n /usr/local/bin cocoapods如果没有反应,则输入:$ gem sources --remove https://rubygems.org/然后再输入:$ gem sources -a http://gems.ruby-china.org/然后再次在终端运行:$ sudo gem install -n /usr/local/bin cocoapods

等会就会安装好滴。

报错问题://如果发生以下问题

$ sudo gem install cocoapodsERROR: While executing gem ... (Gem::FilePermissionError)You don't have write permissions for the /usr/bin directory.$ pod --version/Library/Ruby/Site/2.3.0/rubygems.rb:271:in find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException) from /Library/Ruby/Site/2.3.0/rubygems.rb:299:inactivate_bin_path'from /usr/local/bin/pod:23:in `

'//解决方案://我这里显示已经更新了$ sudo gem update --systemLatest version currently installed. Aborting.$ mkdir -p $HOME/Software/ruby$ export GEM_HOME=$HOME/Software/ruby$ gem install cocoapods显示:Fetching: xcodeproj-1.5.6.gem (100%)Successfully installed xcodeproj-1.5.6Fetching: cocoapods-1.4.0.gem (100%)Successfully installed cocoapods-1.4.0Parsing documentation for xcodeproj-1.5.6Installing ri documentation for xcodeproj-1.5.6Parsing documentation for cocoapods-1.4.0Installing ri documentation for cocoapods-1.4.0Done installing documentation for xcodeproj, cocoapods after 7 seconds2 gems installed

$ export PATH=$PATH:$HOME/Software/ruby/bin//这个时候查看下pod的版本,不报错了$ pod --version显示1.4.0

使用就拿MJRefresh举例,先用终端搜索下$ pod search AFNetworking然后咱创建个Demo项目,在这个项目目录下创建一个叫“Podfile”的文件,这里用终端来创建,我们先到这个项目的目录下,输入$ vim Podfile然后在vim中输入i进入编辑模式source 'https://github.com/CocoaPods/Specs.git'target :RuntimeTest doplatform:ios,'9.0'pod 'MJRefresh', '~> 3.1.15.3'end按esc退出编辑模式,再输入:wq 这样就保存退出了最后运行下面命令$ pod installAnalyzing dependenciesDownloading dependenciesInstalling MJRefresh (3.1.15.3)Generating Pods projectIntegrating client project[!] Please close any current Xcode sessions and use RuntimeTest.xcworkspace for this project from now on.Sending statsPod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.运行成功了然后打开RuntimeTest.xcworkspace这个文件就完事了

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值