模块未找到安装在 flutter 模块中的包的问题(添加到应用程序)

Module not found issue with package installed in flutter module (add-to-app)

我已将 flutter 模块添加到现有的 iOS 应用程序中。 iOS 应用程序在编译时无法找到安装的软件包(通过 pubspec.yaml 文件),但不是全部,只有少数安装,我在 XCode 中收到 'Module not found' 错误。到目前为止,那些有问题的包是:razorpay_flutter、google_maps_flutter、webview_flutter 和 url_launcher。请看下面的截图:

其他3个包也是如此。

重现问题的步骤:

  1. 在pubspec.yaml文件中添加razorpay_flutter: ^1.1.3 颤振模块
  2. 运行flutter pub get。软件包将安装
  3. 运行 Xcode 添加flutter模块的项目。出错了!

我在第 2 步后观察到的另一件事是关于添加到现有应用程序的问题的一些警告:

Running "flutter pub get" in lib_smazing...                         
The plugin `razorpay_flutter` is built using an older version of the Android plugin API which assumes that it's running in a full-Flutter environment. 
It may have undefined behaviors when Flutter is integrated into an existing app as a module.
The plugin can be updated to the v2 Android Plugin APIs by following https://flutter.dev/go/android-plugin-migration.

我猜想使用平台 channel/code 的包在添加到现有应用程序时存在问题,但不确定是它的包特定问题还是 add-to-app 的不稳定问题。

经过几次试验和错误后,我发现 iOS 项目目录中的 运行 pod install 简单地解决了这个问题。

相当琐碎,但意识到找不到我的包,因为我在 XCode 中打开并执行了错误的文件 - 所以打开 Runner.xcworkspace 而不是 Runner.xccodeproj

有多种解决方案可用于任何类型 library/module 未找到。

解决方案#1

flutter clean

再次颤抖运行 再次从 ios 或 vscode 工具重建它。

如果还有问题

pod update

pod repo update

pod install

解决方案#2

delete build folder
delete pod.lock file
delete .syslinks folder
delete pods folder

通过

更改终端中的目录
cd ios
pod install --repo-update OR pod repo update
pod install
flutter clean
flutter pub get

解决方案# 3

please open Runner.xcworkspac with xcode because app will get local lib from pod install lib that installed. , but don't Runner.xcodeproj