0

将包flutter_inappwebview添加到pubspec.yaml. 它抱怨没有安装 CocoaPods。但我仍然可以使用flutter run.

说明此错误的最小项目位于https://github.com/kvutien/my_inappwebview

知道为什么吗?

我的开发配置

  • 配备 M1 Pro 芯片和 macOS 12.1 Monterey 的 Macbook Pro
  • flutter doctor输出:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-LU)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Connected device (2 available)

• No issues found!

如何重现错误

  • 在 Android Studio 中,创建新的 Flutter 项目
  • File > Project Structure > Project > Project SDK中设置使用的 SDK ,选择Android API 32
  • 选择一个 iOS 虚拟设备
  • 从包装盒中运行应用程序以证明它可以工作。
  • 打开将以下行pubspec.yaml添加到该部分dependencies(应该在模板代码的第 29 行),紧挨着下面sdk: flutter
  flutter_inappwebview: ^5.3.2
  • 运行pub get以更新依赖项
  • 使用运行按钮运行应用程序

Android Studio 会抱怨

Launching lib/main.dart on iPad mini (6th generation) in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
  CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
  Without CocoaPods, plugins will not work on iOS or macOS.
  For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

CocoaPods not installed or not in valid state.
Error launching application on iPad mini (6th generation).

仍然可以从 Android Studio 的终端构建和运行

缺少 CocoaPods 和配置中缺少 PATH 都不是问题。

无需更改代码中的任何内容,打开 Android Studio 的终端窗格并输入flutter run. 构建将成功,应用程序将在虚拟设备中运行。

Launching lib/main.dart on iPad mini (6th generation) in debug mode...
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      2,243ms
Xcode build done.                                            8.5s
Syncing files to device iPad mini (6th generation)...               56ms

但 Android Studio 表现良好,请参阅示例flutter_inappwebviewer项目pub.dev

无需从终端运行。

为了证明它:

  • 在 Android Studio 中,创建新的 Flutter 项目
  • 如上设置项目的SDK
  • 选择一个 iOS 虚拟设备
  • main.dart用示例代码替换首字母pub.dev
  • 在中添加依赖项pubspec.yaml
  • pub get
  • 使用Run按钮构建并运行应用程序

Android Studio 不会用这段代码抱怨 CocoaPods。

说明这一点的项目位于https://github.com/kvutien/test_in_app_webview

欢迎任何解释。

4

1 回答 1

0

问题已于 2022 年 2 月 11 日解决。

适用于 macOS M1的 Android Studio 升级Bumblebee 2021.1.1 Patch 1a使该错误消失。从 IDERun按钮运行构建不再产生CocoaPods missing错误消息。

于 2022-02-15T14:33:21.437 回答