flutter运行macos报错:Error: CocoaPods not installed or not in valid state.

Warning: CocoaPods not installed. Skipping pod install.

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

Error: CocoaPods not installed or not in valid state.

处理了很多方案,最后还是用如下方式处理的:

1.打开macOS或者Windows配置文件,如open ~/.bash_profile

2.确保配置文件都是正确的,每行路径开头,不能有空格

3.保存,source ~/.bash_profile

4.查看flutter版本,flutter --version

5.在Android studio中运行一下flutter run

6.其次在在编译器上面运行端点的run

每次put get之后,更新依赖包之后就会出现如上的错误!这样处理就可以运行了;

其他我尝试过的方案,删除过Android studio,删除过cocoapods,升级过各种关于cocoapods,也清除了无数次缓存!

记录一下如下:

bash 复制代码
# 1卸载现有 CocoaPods(如果有问题)
sudo gem uninstall cocoapods

# 重新安装 CocoaPods
sudo gem install cocoapods

# 或者使用 brew 安装
brew install cocoapods
bash 复制代码
# 2更新或重新设置 CocoaPods 仓库
pod repo update

# 或者如果仓库有问题
pod repo remove master
pod setup
bash 复制代码
3在项目目录中重新配置 iOS 依赖
cd ios
pod deintegrate
pod cache clean --all
pod install

4清理 Flutter 构建缓存
flutter clean
cd ios
rm -rf Pods
rm -rf Podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData/*

 5重新获取依赖
flutter pub get
cd ios
pod install
bash 复制代码
1打开终端 (View → Tool Windows → Terminal)
2依次执行以下命令:
flutter clean
flutter pub get
cd ios
pod install
cd ..
flutter run

打开Mac全局配置文件:

open ~/.bash_profile

命令全局运行:

sudo gem install -n /usr/local/bin cocoapods --pre

退出Android studio再进入

导入ruby路径到配置文件

1.flutter clean

  1. put get

  2. pub upgrade

1.pod cache

2.pod clean

3.pod deintegrate

4.pod setup

5.pod install

在项目配置文件中:

6.get dependencies

7.upgrade dependencies

相关推荐
Bigger3 小时前
Flutter 开发实战:解决华为 HarmonyOS 任务列表不显示 App 名称的终极指南
android·flutter·华为
梧桐ty7 小时前
鸿蒙应用冷启动优化:Flutter首屏秒开与白屏治理实战
flutter·华为·harmonyos
梧桐ty8 小时前
驾驭未来:基于鸿蒙的Flutter车载应用与手机端协同实战
flutter·华为·harmonyos
程序员老刘10 小时前
Flutter 3.38 30天发6个版本,Google 程序员的头发还好吗?
flutter·客户端
专业开发者12 小时前
调试 iOS 蓝牙应用的新方法
物联网·macos·ios·cocoa
子榆.16 小时前
Flutter 与开源鸿蒙(OpenHarmony)深度集成实战:从零构建跨平台应用
flutter·开源·harmonyos
恋猫de小郭16 小时前
Flutter UI 设计库解耦重构进度,官方解答未来如何适配
android·前端·flutter
米有哥16 小时前
[Embodied AI] Mac上安装ROS2
人工智能·macos·ros2
2501_9275410918 小时前
Adobe Lightroom Classic 2025 Lrc图像处理工具Mac
图像处理·macos·adobe·lightroom·照片美化
程序员大辉18 小时前
新人学习Flutter,如何搭建开发环境(附所有安装包)
学习·flutter