cocoapods最新踩坑以及更新

cocoapods的更新

pod update 报错
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

解决方法

一、升级openssl,先看版本

openssl version

输出:OpenSSL 0.9.8zh 14 Jan 2016

2、输入

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

可能会要你在回车一下,点击回车键

3、更新brew

brew update

ps:如果提示:Error: /usr/local must be writable!

输入:

liuxin$ sudo chown -R $(whoami) /usr/local

4、install openssl

brew install openssl
brew upgrade openssl

5、输入

which openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

再次查看version

which openssl

输出:/usr/local/opt/openssl/bin/openssl

openssl version

输出:OpenSSL 1.0.2o 27 Mar 2018

二、到这里,openssl就更新完成了,下面更新ruby,输入如下:

brew install rbenv ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

查看当前ruby版本:

ruby --version

输出:ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

我们需要更新到最新的版本,先查看最新版本列表

rvm list known

大概如下,能看到一片内容,找到当前最新到2.4.1

[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]

输入:

rvm install 2.4

如果更新报错:Error running ‘requirements_osx_brew_update_system ruby-2.4.1

根据提示操作
打开.bash_profile

open .bash_profile

把source ~/.profile添加进入
如下面所示:

export PATH="/usr/local/opt/openssl/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
source ~/.profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

再次更新:

1、curl -L get.rvm.io | bash -s stable
2、source ~/.bashrc
3、source ~/.bash_profile
4、rvm -v

然后到这里就更新完了,这个时候,我们就可以导入第三方库
例如:

pod search SDWebImage

输出:

-> SDWebImage (4.0.0)
   Asynchronous image downloader with cache support with an UIImageView
   category.
       pod 'SDWebImage', '~> 4.0.0'
   - Homepage: https://github.com/rs/SDWebImage
   - Source:   https://github.com/rs/SDWebImage.git
   - Versions: 4.0.0, 4.0.0-beta2, 4.0.0-beta, 3.8.2, 3.8.1, 3.8.0, 3.7.6,
   3.7.5, 3.7.4, 3.7.3, 3.7.2, 3.7.1, 3.7.0, 3.6, 3.5.4, 3.5.2, 3.5.1, 3.5, 3.4,
   3.3, 3.2, 3.1, 3.0, 2.7.4, 2.7, 2.6, 2.5, 2.4 [master repo]
   - Subspecs:
     - SDWebImage/Core (4.0.0)
     - SDWebImage/MapKit (4.0.0)
     - SDWebImage/GIF (4.0.0)
     - SDWebImage/WebP (4.0.0)

-> SDWebImage+ExtensionSupport (3.7.1.2)
   Asynchronous image downloader with cache support with an UIImageView
   category. Added SD_APP_EXTENSION macro for ios8 extensions
   pod 'SDWebImage+ExtensionSupport', '~> 3.7.1.2'
   - Homepage: https://github.com/rs/SDWebImage
   - Source:   https://github.com/glassoff/SDWebImage.git
   - Versions: 3.7.1.2, 3.7.1.1 [master repo]

这个时候,我们cd一个项目

然后:

1、touch podfile
2、vim podfile

然后

pod 'AFNetworking', '~> 3.1.0'

最后

pod install

但是这个时候又报错了,
[!] The dependency ` is not used in any concrete target.
[!] The dependency
SDWebImage (~> 4.0.0)` is not used in any concrete target.
解决办法

打开podfile

platform :ios,"8.0"

target "项目名称" do
pod 'SDWebImage', '~> 4.0.0'
end

然后在更新
pod install
显示如下信息,完成

Analyzing dependencies
Downloading dependencies
Installing SDWebImage (4.0.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `cityText.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值