以前安裝CocoaPods文章 傳送門
由于CocoaPods經(jīng)常的更新 出現(xiàn)了一些問題老的文章就就先不改了,這里弄個(gè)續(xù)試試 遇到的問題希望能幫助大家~
CocoaPods 需要有Ruby進(jìn)行更新搜索
Ruby版本管理工具有RVM为迈、Brew艾帐、Ruby出問題了就得更新 以及安裝他的管理工具這樣
首先安裝rvm
curl -L get.rvm.io | bash -s stable
成功 rvm -v
//進(jìn)入RVM 環(huán)境挎塌。
$ 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
又出現(xiàn)個(gè)錯(cuò) 記得是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)"
我選擇的第一個(gè)源
或者
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
訪問此網(wǎng)址:https://brew.idayer.com/
是否成功: brew --version
安裝ruby 我安裝ruby碰到的問題安裝別的安裝不了 系統(tǒng)直接鎖死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"
執(zhí)行完畢后,查看已安裝的ruby
rvm list
設(shè)置為使用版本 以及系統(tǒng)默認(rèn)版本:
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、之前運(yùn)行pod setup奴紧,還會(huì)提示 /usr/local/bin 這個(gè)文件夾只可讀,無法操作,所以更改下他的讀寫權(quán)限
sudo chmod go-w /usr/local/bin
如果出現(xiàn)
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
之后還是不行,但報(bào)錯(cuò)少了,之后繼續(xù)看
說是 [!]未能連接到GitHub以更新CocoaPods/Specs Specs repo-請(qǐng)檢查您是否脫機(jī)用押,或者GitHub是否已關(guān)閉
那我就找唄,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出錯(cuò)
說是沒有找到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
執(zhí)行了下這個(gè) 出現(xiàn)
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
找好一會(huì)方法 試了下能否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.查看網(wǎng)址
打開網(wǎng)站:https://www.ipaddress.com/
查詢一下 `raw.githubusercontent.com`對(duì)應(yīng)的IP 地址
# No rvm rubies installed yet. Try 'rvm help install'.
$ rvm install 2.6
這時(shí)出現(xiàn)個(gè)警告 說是又最新的版本 讓我選擇更新方式 我選擇了自動(dòng)更新
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出了一系列警告 和提示 如果有按提示依次執(zhí)行就行
最后可以檢查ruby環(huán)境 brew doctor 以及版本
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
進(jìn)入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
出現(xiàn)了以上 ruby就成功了 但是成功了之后CocoaPods 還沒有安裝成功
我就執(zhí)行了
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 版本靶剑,網(wǎng)上都是通過 xcode-select --install 來解決蜻拨,但是我在 Mac OS 10.14 版本下池充,依然存在報(bào)錯(cuò)。
最終找到解決方式缎讼,執(zhí)行:
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
命令有點(diǎn)多 一執(zhí)行就給覆蓋了所以后來就沒截圖
下面是一些操作命令,以及方法
如果環(huán)境變量有問題的話
vi ~/.bash_profile
export PATH=/usr/local/rvm/bin:/opt/git1.7.10.2/bin:$PATH
更新環(huán)境變量.
$ source ~/.bashrc
$ source ~/.bash_profile
rvm autolibs read-only
rvm install ruby-2.7
手動(dòng)安裝 //先下載
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
解壓
tar -zxvf rubygems-1.8.24.tgz
放到一個(gè)目錄, (可選)
mv rubygems-1.8.24 /usr/local/rvm/src/
如果遇到 SSL 證書問題收夸,你又無法解決,請(qǐng)修改 ~/.gemrc 文件血崭,增加 ssl_verify_mode: 0 配置卧惜,以便于 RubyGems 可以忽略 SSL 證書錯(cuò)誤。
---
:sources:
- https://gems.ruby-china.com
:ssl_verify_mode: 0
更新安裝 brew的時(shí)候
$ source ~/.bashrc
$ source ~/.bash_profile
$ gem source -u
brew install rbenv ruby-build
ruby-build與rbenv一起使用夹纫。以下幾行安裝Ruby 2.7.2咽瓷,并將其設(shè)置為您的默認(rèn)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 執(zhí)行了下這個(gè)可以了
再不好使
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
//進(jìn)去項(xiàng)目工程執(zhí)行search
pod search bugly
參考文章
http://daemon369.github.io/ruby/2017/12/14/01-install-ruby
pod --version
后報(bào)錯(cuò)遇到
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
如果幫到您了 給個(gè)贊吧~