当前位置: 首页 > java >正文

一路磕磕绊绊解决flutter doctor 报错CocoaPods not installed

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-pluginsFor installation instructions, seehttps://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 againsecurerandom 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

解决方案:

  1. 打开网站,https://www.ipaddress.com/,在此网站中查询一下 raw.githubusercontent.com对应的IP 地址

  1. 配置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.logThere 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 here439 | #  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!

其中艰辛,只有两个字含泪~~~

http://www.xdnf.cn/news/29.html

相关文章:

  • 鸿蒙API15 “一多开发”适配:解锁黄金三角法则,开启高效开发新旅程
  • Gateway
  • 【HDFS入门】HDFS高可用性与容错机制深度解析
  • XC7K410T‑2FFG900I 赛灵思XilinxFPGA Kintex‑7
  • 5.VTK 相机
  • 智能体开发范式革命:Cangjie Magic的颠覆性创新与行业重塑
  • 电控---printf重定向输出
  • BFC详解
  • 4.16 AT好题选做
  • 2026《数据结构》考研复习笔记二(C++面向对象)
  • QML 信号与槽
  • 微信小程序文字混合、填充动画有效果图
  • 全自动驾驶(FSD,Full Self-Driving)自动驾驶热点技术的成熟之处就是能判断道路修复修路,能自动利用类似“人眼”的摄像头进行驾驶!值得学习!
  • SpringBoot项目动态加载jar 实战级别
  • 探索鸡养殖虚拟仿真实验:科技赋能养殖新体验
  • 新型多机器人协作运输系统,轻松应对复杂路面
  • 黑马商城项目(三)微服务
  • IDEA 中 Scala 项目远程连接虚拟机 Spark 环境
  • ubuntu 向右拖动窗口后消失了、找不到了
  • Nodemon vs. PM2:开发与生产环境的 Node.js 部署最佳实践
  • 【FFmpeg从入门到精通】第二章-FFmpeg工具使用基础
  • 数据通信学习笔记之OSPF路由汇总
  • ThingsBoard3.9.1 MQTT Topic(2)
  • iptables防火墙
  • NO.96十六届蓝桥杯备战|图论基础-多源最短路|Floyd|Clear And Present Danger|灾后重建|无向图的最小环问题(C++)
  • Doris FE 常见问题与处理指南
  • 告别昂贵语音合成服务!用GPT-SoVITS生成你的个性化AI语音