温馨提示: 如果在安装中 切换网络 依然出现curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
可参考这篇文章
主要步骤: 前往文件夹 输入 /etc
找到hosts
文件 ,拷贝出来,在里面添加 文章中的几行代码, 保存之后 再替换etc中的hosts
准备环境
1、安装/升级RVM
1.1 确定是否存在RVM
输入 rvm -v
, 查看命令执行是否成功。
如果输出-bash: rvm: command not found
表示RVM不存在,需要安装。
如果输出rvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
表示RVM存在,可以进行下一步。
1.2 安装RVM
如果RVM不存在,需要重新安装。
输入命令curl -L get.rvm.io | bash -s stable
或者curl -L https://get.rvm.io | bash -s stable
会自动开始下载。
macdeiMac:~ mac$ curl -L https://get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 24 0 0:00:08 0:00:08 --:--:-- 44
.....
* To start using RVM you need to run `source /Users/mac/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
出现提示之后,表示下载完成,按照提示,要执行source ~/.rvm/scripts/rvm
来安装。
执行rvm -v
来确定是否安装成功。正确输出,表示安装成功。
1.3 升级RVM
当有新版本的RVM时,想升级了,输入和安装一样的命令:curl -L get.rvm.io | bash -s stable
或者curl -L https://get.rvm.io | bash -s stable
Upgrade of RVM in /Users/jasonOs/.rvm/ is complete.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
查看版本rvm -v
时,有提示
Please open a new shell or run one of the following commands:
rvm reload
echo rvm_auto_reload_flag=1 >> ~/.rvmrc # OR for auto reload with msg
echo rvm_auto_reload_flag=2 >> ~/.rvmrc # OR for silent auto reload
按照提示需要输入某一个命令 ,此时控制台输入rvm reload
1.4 gem 升级
sudo gem update --system
如果报“无权限”,使用
sudo gem update -n /usr/local/bin --system
2、安装 brew
1.1 确定是否存在brew
输入brew -v
,
如果输出-bash: brew: command not found
则没有安装,需要安装。
如果输出brew .....
表示brew存在,可以进行下一步。
1.2 安装brew
官方 --- - ⚠️ 不建议尝试
输入/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
。等待自动下载。
如果出现curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
表示网络环境有问题,可以切换不同的网络试试镜像方式 强烈推荐 NB的飞起
简单五步安装brew
3、升级ruby
参考来源
其实此步骤一般来说是不需要的,因为本来系统自带的应该都是2.3.3(要求最低是2.2)已经满足安装cocoapod的要求了。
查看当前版本ruby - v
如果想升级版本,采用一下方法:
输入命令: brew install ruby
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/ca-certificates-2022-10-11.all.bottle
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/openssl%401.1-1.1.1q.monterey.bottle.
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/readline-8.2.1.monterey.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/ruby-3.1.2_1.monterey.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for ruby: ca-certificates, openssl@1.1 and readline
==> Installing ruby dependency: ca-certificates
==> Pouring ca-certificates-2022-10-11.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺 /usr/local/Cellar/ca-certificates/2022-10-11: 3 files, 225.4KB
==> Installing ruby dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1q.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/openssl@1.1/1.1.1q: 8,097 files, 18.5MB
==> Installing ruby dependency: readline
==> Pouring readline-8.2.1.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/readline/8.2.1: 50 files, 1.7MB
==> Installing ruby
==> Pouring ruby-3.1.2_1.monterey.bottle.tar.gz
==> Caveats
By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/3.1.0/bin
You may want to add this to your PATH.
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ruby first in your PATH, run:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
For compilers to find ruby you may need to set:
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
==> Summary
🍺 /usr/local/Cellar/ruby/3.1.2_1: 15,996 files, 41MB
==> Running `brew cleanup ruby`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> ruby
By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/3.1.0/bin
You may want to add this to your PATH.
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ruby first in your PATH, run:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
For compilers to find ruby you may need to set:
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
安装升级后,再次查看版本,发现还是原来的版本,输入以下命令
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
2、安装CocoaPods
接下来就开始安装cocoapod了
这个步骤参考了这篇文章(但是这篇文章的最后 pod setup不成功)
步骤2、更换Ruby镜像
1、先看现在的镜像地址:
输入命令: gem sources -l
如果是
*** CURRENT SOURCES ***
https://rubygems.org/
需要替换成国内的。如果本身就是国内的镜像,则不需要步骤2的操作
2、替换成国内镜像
先移除现在的镜像
终端输入:
gem sources --remove https://rubygems.org/
然后替换成现在大中华地区可用的(taobao的那个镜像已经不好用了)
gem sources -a https://gems.ruby-china.com/
执行完之后查看是否替换成功
gem sources -l
输出结果
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
说明替换成功
3、镜像替换之后开始进行cocoapods安装
终端输入:
sudo gem install -n /usr/local/bin cocoapods
或者sudo gem install cocoapods -n /usr/local/bin
如果出现权限问题
可更换命令:sudo gem install cocoapods --user-install
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
开始下载之后 会出现以下输出
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.5.gem (100%)
Successfully installed i18n-0.9.5
...................//内容太长的省略
Fetching: cocoapods-1.4.0.gem (100%)
Successfully installed cocoapods-1.4.0
Parsing documentation for concurrent-ruby-1.0.5
Installing ri documentation for concurrent-ruby-1.0.5
Parsing documentation for i18n-0.9.5
Installing ri documentation for i18n-0.9.5
...................//内容太长的省略
Parsing documentation for cocoapods-1.4.0
Installing ri documentation for cocoapods-1.4.0
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 31 seconds
28 gems installed
之后在执行
pod setup
输出
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 2038413, done.
remote: Compressing objects: 100% (6489/6489), done.
Receiving objects: 11% (239182/2038413), 47.75 MiB | 2.00 KiB/s
这是一个漫长的等待。。。
你没有看错,我的速度就是2、2、2 ...不过此时我的内心是平静的【大写的滑稽脸】
你可以command+n
新建一个终端窗口,执行cd ~/.cocoapods/
进入到该文件夹下,然后执行du -sh *
来查看大小,每隔几分钟查看一次,他会告诉你,确实是有文件在往里面写【无聊脸】
等待了2个小时之后 见红了 。。。
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 2038413, done.
remote: Compressing objects: 100% (6489/6489), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我平静的内心依然毫无波澜。。。
在一个文章上找到了解决方案
1、卸载cocoapod(感觉这一步可以省略)
终端输入:
sudo gem uninstall cocoapods
这个时候需要输入电脑密码(请注意,输入密码不是显示,光标也不会动)输入密码之后
此时终端输出:
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn]
需要你输入 ‘Y’ 按enter键
终端继续输出:
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.4.0
2、重装cocoapods
终端输入:
sudo gem install -n /usr/local/bin cocoapods
终端输出:
Fetching: cocoapods-1.4.0.gem (100%)
Successfully installed cocoapods-1.4.0
Parsing documentation for cocoapods-1.4.0
Installing ri documentation for cocoapods-1.4.0
Done installing documentation for cocoapods after 4 seconds
1 gem installed
终端输入
sudo chmod +rx /usr/local/bin
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
pod setup
此时终端输出:
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 2038845, done.
remote: Compressing objects: 100% (6896/6896), done.
Receiving objects: 31% (648027/2038845), 111.18 MiB | 126.00 KiB/s
此时的速度比刚才比,内心已经震精了。。。
上面的进度跑完之后会继续跑下面这行
Resolving deltas: 37% (423306/1144069)
跑完还会跑
Checking out files: 10% (22244/227244)
100%后就看到了期待已久的输出:
CocoaPods 1.5.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0.beta.1
Setup completed
completed..............................................
此时我的内心汹涌澎湃。。。。。
最后全部安装完整之后 查看了文件大小 1.5G,不敢想象如果用2k的速度,得用多久, 之前也试过,进行pod setup跑了1天 大概到80%几,见红了。。。
Cloning spec repo cocoapods
卡住
cocoaPod安装完之后, 第一次进行pod install
操作。可能会出现卡住不动或者的情况,只是由于cocoapPod安装好了, 但是必要的资源还没准备好,后台在默默的下载,具体大小,可根据git的api中的size查看
Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/98-elden/.cocoapods/repos` or via `pod repo add`.
解决办法:
1、去git仓库下载好资源,倒入本地文件夹下.cocoapods/repos/cocoapods/
解决方法来源
安装cocoapod之后,提示 gem executables will not run
https://www.jianshu.com/p/6f4f253bc254
2、换源
步骤1、更换国内的镜像, 清华的不错
解决方法来源
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
步骤2、项目中的podfile文件修改源地址:
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
更新时遇到警告
WARNING: You don't have /Users/xxx/.local/share/gem/ruby/2.6.0/bin in your PATH,
gem executables will not run.
解决方案:来源于stackoverflow
# 1、打开配置文件
open ~/.zshrc
# 2、在最后加以下2行:
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
# 3、重置资源
source ~/.zshrc
放弃了系统的ruby,用第三方代替
由于各种权限问题, 放弃了系统的ruby。安装了rbenv 参考这里安装
curl: (92) HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
[!] Error installing MintegralAdSDK
[!] /usr/bin/curl -f -L -o /var/folders/2m/w24z1m4d1qd2dz_yy15lv6280000gn/T/d20231101-83686-mur3p2/file.zip https://github.com/Mintegral-official/MintegralAdSDK-iOS-new/releases/download/7.4.2/Mintegral_M_SDK.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.14.2 cocoapods-downloader/2.0'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:02:00 --:--:-- 0
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 的时候发现一直提示 HTTP/2 stream 1 was not closed cleanly before end of the underlying stream。 通过排查发现,是 git 默认使用的通信协议出现了问题,可以通过将默认通信协议修改为 http/1.1 来解决该问题。
The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods inst
一个cocos2d的工程构件出来的Xcode工程,然后在创建了podfile进行pod 运行后就报错
The singleCarGame-mobile [Debug]
target overrides the HEADER_SEARCH_PATHS
build setting defined in `Pods/Target Support Files/Pods-singleCarGame-mobile/Pods-singleCarGame-mobile.debug.xcconfig'. This can lead to problems with the CocoaPods installation
The `singleCarGame-mobile [Debug]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-singleCarGame-mobile/Pods-singleCarGame-mobile.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.