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

一路磕磕绊绊解决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!

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

相关文章:

  • 【软件系统架构】事件驱动架构
  • 【音视频】MP4解封装
  • [特殊字符] 基于大模型的地理领域文档中英互译自动化方案
  • React 组件类型详解:类组件 vs. 函数组件
  • 【并行分布计算】Hadoop完全分布搭建
  • 【机器学习】大数据时代,模型训练慢如牛?解锁Spark MLlib与分布式策略
  • 【ROS】局部规划器概述
  • 抽象的https原理简介
  • React JSX 语法深度解析与最佳实践
  • 第九节:React HooksReact 18+新特性-React 19的use钩子如何简化异步操作?
  • React 开放封闭原则详解,构建可扩展的应用
  • React Native 0.79 稳定版发布,更快的工具、更多改进
  • 6、事件处理法典:魔杖交互艺术——React 19 交互实现
  • MySQL数据库安装配置详细教程
  • AUTOSAR图解==>AUTOSAR_SWS_DefaultErrorTracer
  • 网络层IP协议知识大梳理
  • 探寻Gson解析遇到不存在键值时引发的Kotlin的空指针异常的原因
  • docker Windows 存放位置
  • k8s 手动续订证书
  • LoRA个关键超参数:`LoRA_rank`(通常简称为 `rank` 或 `r`)和 `LoRA_alpha`(通常简称为 `alpha`)
  • 白玉兰奖评委会主席陈宝国:好作品要有筋骨有血肉更要有戏魂
  • 同济大学党委常务副书记冯身洪履新中国科协党组副书记
  • 上影节开幕影片《酱园弄·悬案》,陈可辛执导,章子怡主演
  • 北京人艺新戏《一日顶流》将出现人工智能角色
  • 66岁华仁世纪集团有限公司创始人、董事长梁福东逝世
  • 一日双赛“莎头组合”赢得强势,但国乒已开始品尝输球滋味