颤动错误:“CocoaPods 未安装或未处于有效状态。”

Tho*_*hoe 7 xcode ios cocoapods flutter

问题可能是 Android Studio 找不到 CocoaPods 的路径吗?

\n

我正在尝试通过 Android Studio 在 iPhone 上测试我的应用程序。我得到的错误是

\n
Warning: CocoaPods not installed. Skipping pod install.\n  CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.\n  Without CocoaPods, plugins will not work on iOS or macOS.\n  For more info, see https://flutter.dev/platform-plugins\nTo install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.\n\nException: CocoaPods not installed or not in valid state.\n
Run Code Online (Sandbox Code Playgroud)\n

我跑了gem list并安装了 gem 的列表包括:

\n
gem list\n \ncocoapods (1.11.2)\ncocoapods-core (1.11.2)\ncocoapods-deintegrate (1.0.5)\ncocoapods-downloader (1.5.1)\ncocoapods-plugins (1.0.0)\ncocoapods-search (1.0.1)\ncocoapods-trunk (1.6.0)\ncocoapods-try (1.2.0)\n
Run Code Online (Sandbox Code Playgroud)\n

我跑了

\n
sudo gem uninstall cocoapods && sudo gem install cocoapods\n
Run Code Online (Sandbox Code Playgroud)\n

我跑了

\n
flutter clean\n
Run Code Online (Sandbox Code Playgroud)\n

我重新启动了 Android Studio。

\n

我跑了File > Invalidate Caches\xe2\x80\xa6 > Invalidate and Restart

\n

我跑了

\n
cd ios\npod install\n
Run Code Online (Sandbox Code Playgroud)\n

这引发了这个错误:

\n
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).\n
Run Code Online (Sandbox Code Playgroud)\n

Stack Overflow 对该错误消息的回答是修复 Xcode 中的问题。但是当我尝试在 Xcode 中打开 Android Studio 项目时,出现以下错误:

\n
Could not open file. (/Users/TDK/StudioProjects/Kabbalah)\n
Run Code Online (Sandbox Code Playgroud)\n

这是一件奇怪的事情。当我卸载时cocoapods它们不会消失:

\n
sudo gem uninstall cocoapods\nRemove executables:\n        pod, sandbox-pod\n\nin addition to the gem? [Yn]  \nRemoving pod\nRemoving sandbox-pod\nSuccessfully uninstalled cocoapods-1.11.2\n\xe2\x9e\x9c  Kabbalah git:(main) \xe2\x9c\x97 gem list\n\n*** LOCAL GEMS ***\n\nabbrev (default: 0.1.0)\nactivesupport (6.1.4.4)\naddressable (2.8.0)\nalgoliasearch (1.27.5)\natomos (0.1.3)\nbase64 (default: 0.1.0)\nbenchmark (default: 0.1.1)\nbigdecimal (default: 3.0.0)\nbundler (default: 2.2.32)\nbundler-unload (1.0.2)\nCFPropertyList (3.0.5)\ncgi (default: 0.2.1)\nclaide (1.1.0, 1.0.3)\ncocoapods (1.11.2)\ncocoapods-core (1.11.2)\ncocoapods-deintegrate (1.0.5)\ncocoapods-downloader (1.5.1)\ncocoapods-plugins (1.0.0)\ncocoapods-search (1.0.1)\ncocoapods-trunk (1.6.0)\ncocoapods-try (1.2.0)\n\n
Run Code Online (Sandbox Code Playgroud)\n

接下来我该怎么办?如果这不是很明显,我不知道如何使用 Xcode。

\n

Tho*_*hoe 6

IssueTracker上的回复说

Mac 上的 Android Studio Bumblebee 存在此问题。从 IDE 启动 flutter 会导致找不到 Cocoapods 路径的问题。

被迫从终端运行 flutter 才能工作。

以下是如何在 iOS 模拟器上从 CLI 运行项目。cd进入您的项目目录并运行:

flutter emulators --launch apple_ios_simulator
flutter run lib/main.dart 
Run Code Online (Sandbox Code Playgroud)

要通过 CLI 在连接的 iPhone 上运行项目:

flutter devices
Run Code Online (Sandbox Code Playgroud)

您将看到模拟器和您的 iPhone 的列表。现在运行:

flutter run -d 00008030-0010783414089022
Run Code Online (Sandbox Code Playgroud)

用你的 iPhone ID,而不是我的 ID。

lib/main.dart这将在您的 iPhone 上启动。


Tho*_*hoe 1

该错误已在 Bumblebee 2021.1.1 补丁 #1(2022 年 2 月 9 日发布)中修复。