flutter doctor
执行之后,出现以下错误:
错误消息:
✗ CocoaPods not installed.
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
For installation instructions, see
https://guides.cocoapods.org/using/getting-started.html#installation
解决方案:flutter官网参考:https://docs.flutter.dev/get-started/install/macos/mobile-ios#install-cocoapods
安装命令:
# 查看安装进度,在最后加上-V
sudo gem install cocoapods -V
等了N分钟,再次报错。
错误消息:
ERROR: Error installing cocoapods:
The last version of securerandom (>= 0.3) to support your Ruby & RubyGems was 0.3.2. Try installing it with `gem install securerandom -v 0.3.2` and then running the current command again
securerandom requires Ruby version >= 3.1.0. The current ruby version is 2.6.10.210.
提示Ruby版本低了,升级Ruby版本。
网上方案很多,这里采用rvm版本管理的方式进行修复。更多工具参考
rvm安装参考:https://rvm.io/
执行命令:
\curl -sSL https://get.rvm.io | bash -s stable
又又报错了!
错误消息:curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 14 ms: Couldn’t connect to server
解决方案:
- 打开网站,https://www.ipaddress.com/,在此网站中查询一下 raw.githubusercontent.com对应的IP 地址
- 配置hosts文件
185.199.108.133 raw.githubusercontent.com
再去执行:
\curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Installing RVM to /Users/xxx/.rvm/
Adding rvm PATH line to /Users/xxx/.profile /Users/xxx/.mkshrc /Users/xxx/.bashrc /Users/xxx/.zshrc.
Adding rvm loading line to /Users/xxx/.profile /Users/xxx/.bash_profile /Users/xxx/.zlogin.
Installation of RVM in /Users/xxx/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/yangdong/.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.
提示还需执行:
source /Users/xxx/.rvm/scripts/rvm
才能生效。
查看是否安装成功:
rvm --version
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
使用rvm安装Ruby:
rvm install "ruby-3.4.3"
下载有点慢~
我丢,又特么报错了!
ruby-3.4.3 - #extracting ruby-3.4.3 to /Users/xxxx/.rvm/src/ruby-3.4.3 - please wait
ruby-3.4.3 - #configuring - please wait
ruby-3.4.3 - #post-configuration - please wait
ruby-3.4.3 - #compiling - please wait
Error running '__rvm_make -j10',
please read /Users/xxx/.rvm/log/1744902490_ruby-3.4.3/make.log
There has been an error while running make. Halting the installation.
查看报错:
cat /Users/xxx/.rvm/log/1744902490_ruby-3.4.3/make.log
具体报错信息:
./openssl_missing.h:195:11: warning: 'TS_VERIFY_CTS_set_certs' macro redefined [-Wmacro-redefined]
195 | # define TS_VERIFY_CTS_set_certs(ctx, crts) ((ctx)->certs=(crts))
| ^
/opt/homebrew/Cellar/openssl@3/3.4.1/include/openssl/ts.h:439:11: note: previous definition is here
439 | # define TS_VERIFY_CTS_set_certs(ctx, cert) TS_VERIFY_CTX_set_certs(ctx,cert)
| ^
查资料大概意思:
报错是发生在openssl@3,大概原因应该就是安装Ruby的时候需要编译用到openssl, 但是没有指定openssl路径的情况下,它就会默认到
/usr/local/Cellar
下的openssl使用,但是正常使用brew 更新或者安装过openssl的话路径并不在这里,应该在/usr/local/opt/openssl@3
或者/opt/homebrew/Cellar/openssl@3
这里,具体位置报错信息有提示。这也就是导致编译的时候openssl的某些方法找不到等等错误。
解决方案:
rvm install 3.4.3 --with-openssl-dir=`brew --prefix openssl` | rvm install 3.4.3 --with-openssl-dir='/opt/homebrew/Cellar/openssl@3'
等半天~
Install of ruby-3.4.3 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
终于成功了!
查看Ruby版本:
ruby --version
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [arm64-darwin24]
再次执行sudo gem install cocoapods -V
尼玛,又报错了~
具体报错信息:
OpenSSL is not available. Install OpenSSL and rebuild Ruby or use non-HTTPS sources (Gem::Exception)
解决方案:
rvm reinstall 3.4.3 --with-openssl-dir=`brew --prefix openssl`
再去执行:sudo gem install cocoapods -V
终于可以了~~~耐心等待中!
Successfully installed cocoapods-1.16.2
34 gems installed
啥也不说了,特么终于安装上了!!!
再次执行flutter doctor
输出信息:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4 24E248 darwin-arm64, locale zh-Hans-001)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.6)
[✓] VS Code (version 1.98.2)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
其中艰辛,只有两个字含泪~~~