以前安装CocoaPods文章 传送门
由于CocoaPods经常的更新 出现了一些问题老的文章就就先不改了,这里弄个续试试 遇到的问题希望能帮助大家~
CocoaPods 需要有Ruby进行更新搜索
Ruby版本管理工具有rbenv、RVM 所以Ruby出问题了就得更新 以及安装他的管理工具这样
$ /usr/local/bin/git -C /Users/LXS/.cocoapods/repos/master fetch origin
--progress
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
1、之前运行pod setup,还会提示 /usr/local/bin 这个文件夹只可读,无法操作,我先更改下他的读写权限
sudo chmod go-w /usr/local/bin

之后还是不行,但报错少了,之后继续看
说是 [!]未能连接到GitHub以更新CocoaPods/Specs Specs repo-请检查您是否脱机,或者GitHub是否已关闭
那我就找呗,GitHub我安装了 我觉得版本的问题所以我决定把之前的都重新卸载



我又检查了下Gem没问题最新的 再装CocoaPods出错
说是没有找到Gem头文件 那我就弄gem
lxs-macdeMBP-2:~ LXS$ sudo gem install -n /usr/local/bin cocoapods
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200718-36629-1xuhmuh.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.13.1/gem_make.out
lxs-macdeMBP-2:~ LXS$ curl -L https://get.rvm.io | bash -s stable
执行了下这个 出现
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
找好一会方法 试了下能否ping通 所以在代理下加入
199.232.68.133 raw.githubusercontent.com
再次运行OK 图片就不上了占地方 gem下载好了就差不多了吧 我运行还不行 之后就继续找原因 好像是rvm没装 那继续呗 反正今天有时间 弄他!!奥利给。。
可能有些步骤可以跳过 走弯路了 但是没人请教就自己弄吧
lxs-macdeMBP-2:~ LXS$ brew -v
-bash: brew: command not found
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
`https://raw.githubusercontent.com/Homebrew/install/master/install`,我打不开
所以下面是我的解决办法:
### 1\. 解决方式一
> 1.查看网址
打开网站[](https://links.jianshu.com/go?to=%255Bhttps%3A%2F%2Fwww.ipaddress.com%2F%255D%28https%3A%2F%2Fwww.ipaddress.com%2F%29)[https://www.ipaddress.com/](https://links.jianshu.com/go?to=https%3A%2F%2Fwww.ipaddress.com%2F)
查询一下 `raw.githubusercontent.com`对应的IP 地址
//进入RVM 环境。
lxs-macdeMBP-2:~ LXS$ source ~/.rvm/scripts/rvm
//查看rvm版本
lxs-macdeMBP-2:~ LXS$ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
lxs-macdeMBP-2:~ LXS$ rvm list
# No rvm rubies installed yet. Try 'rvm help install'.
lxs-macdeMBP-2:~ LXS$ rvm install 2.6
这时出现个警告 说是又最新的版本 让我选择更新方式 我选择了自动更新
echo rvm_autoupdate_flag=2>>~/.rvmrc
Installing requirements for osx.
Updating system...........Failed to update Homebrew, follow instructions at
https://docs.brew.sh/Common-Issues
and make sure `brew update` works before continuing.
Error running 'requirements_osx_brew_update_system ruby-2.6.3',
please read /Users/LXS/.rvm/log/1595065720_ruby-2.6.3/update_system.log
Requirements installation failed with status: 1.
lxs-macdeMBP-2:~ LXS$ brew update
-bash: brew: command not found
又出现个错 好像是brew gem 不行我就先试试下面 以前弄过 之后就等待~
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo rvm_auto_reload_flag=2>>~/.rvmrc
\curl -sSL https://get.rvm.io | bash -s stable
curl -L get.rvm.io | bash -s stable
rvm reload
等等一些列操作
之后出了装ruby出了一系列警告 和提示
反正最后如果
brew doctor
以及 检查ruby环境
lxs-macdeMBP-2:~ LXS$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
进入rvm
source ~/.rvm/scripts/rvm
lxs-macdeMBP-2:~ LXS$ rvm -v
rvm 1.29.10-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
lxs-macdeMBP-2:~ LXS$ rvm list
ruby-2.7.1 [ x86_64 ]
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
出现了以上 ruby就成功了 但是成功了之后CocoaPods 还没有安装成功
我就执行了
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
lxs-macdeMBP-2:~ LXS$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
如果是之前的 Mac OS 版本,网上都是通过 xcode-select --install 来解决,但是我在 Mac OS 10.14 版本下,依然存在报错。
最终找到解决方式,执行:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
再次
sudo gem install -n /usr/local/bin cocoapods
成功
pod setup
Setup completed
命令有点多 一执行就给覆盖了所以后来就没截图
下面是一些操作命令,以及方法
如果环境变量有问题的话
vi ~/.bash_profile
export PATH=/usr/local/rvm/bin:/opt/git1.7.10.2/bin:$PATH
更新环境变量.
$ source ~/.bashrc
$ source ~/.bash_profile
rvm autolibs read-only
rvm install ruby-2.7
手动安装 //先下载
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
解压
tar -zxvf rubygems-1.8.24.tgz
放到一个目录, (可选)
mv rubygems-1.8.24 /usr/local/rvm/src/
如果遇到 SSL 证书问题,你又无法解决,请修改 ~/.gemrc 文件,增加 ssl_verify_mode: 0 配置,以便于 RubyGems 可以忽略 SSL 证书错误。
---
:sources:
- https://gems.ruby-china.com
:ssl_verify_mode: 0
还有
pod setup
Setup completed 都好使了
pod search Bugly 不成功 之后一顿操作猛如虎
pod repo remove trunk
最后执行了下这个好使了
更新安装 brew的时候
lxs-macdeMBP-2:~ LXS$ source ~/.bashrc
lxs-macdeMBP-2:~ LXS$ source ~/.bash_profile
lxs-macdeMBP-2:~ LXS$ gem source -u
brew install rbenv ruby-build
参考文章
https://www.jianshu.com/p/73823f9e7ad5
https://www.jianshu.com/p/cd8b622c5bfb
http://daemon369.github.io/ruby/2017/12/14/01-install-ruby
如果帮到您了 给个赞吧~
网友评论