以前安装CocoaPods文章 传送门
由于CocoaPods经常的更新 出现了一些问题老的文章就就先不改了,这里弄个续试试 遇到的问题希望能帮助大家~
CocoaPods 需要有Ruby进行更新搜索
Ruby版本管理工具有RVM、Brew、Ruby出问题了就得更新 以及安装他的管理工具这样
首先安装rvm
curl -L get.rvm.io | bash -s stable
成功 rvm -v
//进入RVM 环境。
$ source ~/.rvm/scripts/rvm
//查看rvm版本
$ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ rvm list
$ 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
等等一些列操作
之后安装Homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
我选择的第一个源
或者
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
访问此网址:https://brew.idayer.com/
是否成功: brew --version
安装ruby 我安装ruby碰到的问题安装别的安装不了 系统直接锁死2.6
rvm osx-ssl-certs update /opt/homebrew/etc/openssl@1.1/cert.pem
列出已有的版本:
rvm list known
rvm install "ruby-2.7.1"
rvm install "ruby-2.7.2"
rvm install "ruby-3.0.0"
执行完毕后,查看已安装的ruby
rvm list
设置为使用版本 以及系统默认版本:
rvm use 2.7.2 --default
ruby -v
brew install cocoapods
sudo gem install -n /usr/local/bin cocoapods -v 1.8.3
$ /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
如果出现
curl: (92) HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
git config --global http.version HTTP/1.1
git config --global http.postBuffer 524288000
之后还是不行,但报错少了,之后继续看
说是 [!]未能连接到GitHub以更新CocoaPods/Specs Specs repo-请检查您是否脱机,或者GitHub是否已关闭
那我就找呗,GitHub我安装了 我觉得版本的问题所以我决定把之前的都重新卸载
gem list --local | grep cocoapods
gem uninstall cocoapods && \
sudo gem uninstall cocoapods-core && \
sudo gem uninstall cocoapods-deintegrate && \
sudo gem uninstall cocoapods-downloader && \
sudo gem uninstall cocoapods-plugins && \
sudo gem uninstall cocoapods-search && \
sudo gem uninstall cocoapods-stats && \
sudo gem uninstall cocoapods-trunk && \
sudo gem uninstall cocoapods-try
我又检查了下Gem没问题最新的 再装CocoaPods出错
说是没有找到Gem头文件 那我就弄gem
$ 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
$ 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
$ 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://www.ipaddress.com/
查询一下 `raw.githubusercontent.com`对应的IP 地址
# No rvm rubies installed yet. Try 'rvm help install'.
$ 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/xxx/.rvm/log/1595065720_ruby-2.6.3/update_system.log
Requirements installation failed with status: 1.
之后成功 ruby出了一系列警告 和提示 如果有按提示依次执行就行
最后可以检查ruby环境 brew doctor 以及版本
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
进入rvm
source ~/.rvm/scripts/rvm
$ rvm -v
rvm 1.29.10-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ 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
$ 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
更新安装 brew的时候
$ source ~/.bashrc
$ source ~/.bash_profile
$ gem source -u
brew install rbenv ruby-build
ruby-build与rbenv一起使用。以下几行安装Ruby 2.7.2,并将其设置为您的默认Ruby版本:
$ brew update
$ brew install ruby-build
$ brew install rbenv
$ rbenv install 2.7.2
$ rbenv global 2.7.2
brew install openssl@1.1
以及
pod setup
Setup completed 都好使了
pod search Bugly 不成功
[!] Unable to find a pod with name, author, summary, or description matching `
之后一顿操作猛如虎 pod repo remove trunk 执行了下这个可以了
再不好使
pod repo remove master
cd ~/.cocoapods/repos
git clone --depth 1 https://github.com/CocoaPods/Specs.git master
rm ~/Library/Caches/CocoaPods/search_index.json
//进去项目工程执行search
pod search bugly
参考文章
http://daemon369.github.io/ruby/2017/12/14/01-install-ruby
pod --version
后报错遇到
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.4.12). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.4.12`.
Could not find proper version of cocoapods (1.12.1) in any of the sources
Run `bundle install` to install missing gems.
解决 命令:
gem update --system 3.0.8 && gem update --system
如果帮到您了 给个赞吧~