简体   繁体   English

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

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

I have flutter module added to the existing iOS app.我已将 flutter 模块添加到现有的 iOS 应用程序中。 Not all but few of the packages installed (via pubspec.yaml file) could not be found by the iOS app when compiled, and I'm getting 'Module not found' error in XCode. iOS 应用程序在编译时无法找到安装的所有包(通过 pubspec.yaml 文件),但我在 Z146184A44F38217CC13C54095A 中出现“找不到模块”错误Those problematic packages are: razorpay_flutter, google_maps_flutter, webview_flutter, and url_launcher until now.到目前为止,这些有问题的包是:razorpay_flutter、google_maps_flutter、webview_flutter 和 url_launcher。 Please have a look at screenshot below:请看下面的截图:

在此处输入图像描述

Same is the case with other 3 packages.其他 3 个包的情况也是如此。

Steps to reproduce issue:重现问题的步骤:

  1. Add razorpay_flutter: ^1.1.3 in the pubspec.yaml file of the flutter module在 flutter 模块的 pubspec.yaml 文件中添加razorpay_flutter: ^1.1.3
  2. Run flutter pub get .运行flutter pub get The package will install package 将安装
  3. Run Xcode project to which flutter module is added.运行添加了 flutter 模块的 Xcode 项目。 Got error!有错误!

One more thing I observed after step 2, that there is some warning regarding issue for add to existing app:在第 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.

I guess there is issue with the packages using platform channel/code when added to an existing app, but not sure whether its package-specific issue or a flutter issue with add-to-app.我猜在添加到现有应用程序时使用平台通道/代码的包存在问题,但不确定是特定于包的问题还是添加到应用程序的 flutter 问题。

After few trials and error I found simply running pod install on iOS project directory fixed the issue.经过几次试验和错误后,我发现只需在 iOS 项目目录上运行pod install即可解决问题。

Rather trivial but realized my packages were not found because I opened and executed the wrong file in XCode - so open Runner.xcworkspace and not Runner.xccodeproj相当微不足道,但意识到我的包没有找到,因为我在 XCode 中打开并执行了错误的文件 - 所以打开Runner.xcworkspace而不是Runner.xccodeproj

There are multiple solutions available for any kind of library/module not found.有多种解决方案可用于未找到的任何类型的库/模块。

Solution # 1解决方案#1

flutter clean flutter 清洁

flutter run again rebuild it from ios or vscode tool again. flutter 再次运行从 ios 或 vscode 工具再次重建它。

if still problem如果还有问题

pod update吊舱更新

pod repo update Pod 存储库更新

pod install吊舱安装

Solution# 2解决方案#2

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

change your directory in your terminal by通过以下方式更改终端中的目录

cd ios
pod install --repo-update OR pod repo update
pod install
flutter clean
flutter pub get

Solution# 3解决方案#3

please open Runner.xcworkspac with xcode because app will get local lib from pod install lib that installed.请使用 xcode 打开 Runner.xcworkspac,因为应用程序将从安装的 pod install lib 获取本地 lib。 , but don't Runner.xcodeproj ,但不要 Runner.xcodeproj

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM