CocoaPods 未安装或未处于有效状态

rah*_*wat 36 ios dart flutter

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Warning: CocoaPods is installed but broken. Skipping pod install.
  You appear to have CocoaPods installed but it is not working.
  This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
  This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.
To re-install:
  sudo gem install cocoapods

CocoaPods not installed or not in valid state.
Error launching application on iPhone 11 Pro Max.
Run Code Online (Sandbox Code Playgroud)

小智 115

我认识的一个人遇到了这个问题,另一个人推荐了这个修复程序。

从终端运行此命令:

open /Applications/Android\ Studio.app
Run Code Online (Sandbox Code Playgroud)

问题是有 3 个可能的资源路径,您可以在其中放置配置路径......

  • 一个是 ~/.profile
  • 第二是~/.zshrc。
  • 第三是~/.bashrc。

因此,当您的配置路径不在 ~/.profile 文件中时,将无法从启动板的打开链接访问它。每当您打开终端会话时,所有 3 个路径都会自动同步。这就是区别。

  • 从命令行开始解决了这个问题,但我真的很好奇如何才能真正解决这个问题...... (6认同)
  • 运行一次“open /Applications/Android\ Studio.app”后,在我的情况下,路径似乎已修复,因此无需再次从命令行运行,并且从播放按钮运行也已修复。 (6认同)
  • 奇怪的是,从 Android Studio 的终端运行“flutter run”可以正常工作,但单击播放按钮却不起作用。 (4认同)

小智 37

我也有类似的问题。我刚刚做了以下几件事。

  1. flutter clean
  2. flutter pub get
  3. 重新加载 VSCode
  4. flutter run

  • 我从命令行执行“flutter run”后,它工作正常。 (2认同)

小智 30

通常发生这种情况是由于 Visual Studio 或 IntelliJ 无法找到路径或相关的插件或扩展。解决方案:

  1. sudo gem 卸载 cocoapods sudo gem 安装 cocoapods
  2. 重新启动 IDE 或编辑器

如果不完全关闭项目,最后一步应该可以解决问题

  • 只需重新启动我的 IDE 就可以解决这个问题。 (56认同)
  • 这对我不起作用。奇怪的是,通过 Xcode 运行“flutter run”可以工作,但不能从 Android Studio 运行。 (16认同)
  • 对我来说,技巧是完全关闭 VS Code。 (5认同)
  • @Zenko 同上!对我来说也是一样。当我从命令行运行命令“flutter run”时,它也可以工作。但只是在 Android Studio 上不行。 (4认同)
  • 谢谢。只需重新启动 IDE 对我有用 (3认同)

Yon*_*aor 21

我花了大约一个小时尝试这里的一切。

最后,我发现在 Mac 上,您必须从顶部菜单退出 VS code,而不仅仅是关闭打开的窗口。

希望它能减轻某人的挫败感。


GJJ*_*GJJ 16

用于brew安装cocoapods

  1. sudo gem uninstall cocoapods
  2. brew install cocoapods
  3. brew link --overwrite cocoapods

如果需要取消链接并再次链接brew unlink cocoapods && brew link cocoapods


小智 14

这个问题可能是因为你安装了多个版本的 cocoapods。

您可以检查并解决它运行:

  • gem list 检查是否安装了多个版本的 cocoapod
  • sudo gem uninstall cocoapods 它会提示您选择卸载哪个,或者是否要全部卸载
  • sudo gem install cocoapods

如果您卸载了所有 cocoapods,则附加步骤

  • 切换到你的 Flutter 项目的 iOS 目录
  • pod install

然后应该允许您在 iOS 设备上运行 xcode 构建。


Ash*_*bhu 14

以下内容在我的案例中有效:

brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods
Run Code Online (Sandbox Code Playgroud)

有关此问题的更多信息,请访问: https: //github.com/CocoaPods/CocoaPods/issues/8955

  • 我花了好几天的时间来修复我破损的可可足类动物,但这做到了。另外,只有在其他一切都失败后才将其作为最后的手段。 (2认同)

小智 11

在视觉代码上重新安装颤振扩展修复了这个问题

  • ^ 我查看了这个答案并尝试在我的 IDEA 上更新 Flutter 插件。有用。@MyKoryto 它不应该出现在评论中。 (8认同)
  • 它也适用于 AndroidStudio,当我将 Xcode 更新到 Xcode 13.2 时,我在 Android Studio 上遇到了同样的问题,我的项目在 Xcode 上完美运行,但在 Android Studio 中运行不佳 (2认同)

Bas*_*nth 9

在 Android Studio 上,“无效缓存/重启..”对我有用。


Muh*_*lam 8

我遇到过同样的问题。以下为我工作

  1. 清洁工程
  2. 用户终端颤动运行
  3. 它是与 IDE 相关的问题,而不是 flutter 或 cocoapods

  • `flutter run` 适用于我,但不适用于 Android Studio,我现在不知道如何修复它。 (7认同)
  • @Zenko 解决方法是通过终端启动 Android Studio:`open /Applications/Android\ Studio.app` (6认同)
  • 这确实有效,但是我们如何才能永久修复它呢? (2认同)

mrv*_*nzo 7

如果您使用Visual Studio Code进行 Flutter 开发,该问题可能与解析 shell 环境失败有关:

\n

在此输入图像描述

\n

很多时候,当从 UI(Spotlight、Dock 等)运行时,Visual Studio Code无法按时加载 shell 环境变量(无论您使用哪个 shell - bashzsh等)。因此,PATH和其他环境变量未(正确)加载,这可能导致“ CocoaPods 未安装或未处于有效状态”错误。

\n

解决方法是从终端运行Visual Studio Code(而不是从 UI 启动它),然后照常继续进行 MacOS/iOS 编译,即

\n

open -a "Visual Studio Code"

\n

(或者只是code如果您遵循本指南并将Visual Studio Code添加到PATH环境变量)

\n

\xe2\x9d\x97\xef\xb8\x8f\xe2\x9d\x97\xef\xb8\x8f\xe2\x9d\x97\xef\xb8\x8f 无需重新安装 CocoaPods/Flutter 插件 \xe2\x9d\ x97\xef\xb8\x8f\xe2\x9d\x97\xef\xb8\x8f\xe2\x9d\x97\xef\xb8\x8f

\n


小智 6

我尝试了 heymonkeyriot 提出的解决方案,但这还不够。对我有用的是卸载 cocoapods (当被问及删除 pod 时回答 Y)和 cocoapods-core,然后重新安装 cocoapods 并运行 pod install :

sudo gem list
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)

更改为我的项目的 ios 目录

pod install
Run Code Online (Sandbox Code Playgroud)


Mat*_*tia 5

尝试:

pod setup
brew link --overwrite cocoapods
Run Code Online (Sandbox Code Playgroud)

命令后,重新启动IDE


小智 5

我有同样的问题,我可以在 xcode 中运行,但不能在 vscode 中运行。以下为我工作。

  1. 扑干净
  2. 重启 vscode