真实iOS设备上的Flutter错误:"找不到模块'fluttertoast'"

6
我的Flutter应用在iOS模拟器中正常工作。
我通过以下方式添加了fluttertoast
  1. 在pubspec.yaml中添加

    dependencies: flutter: sdk: flutter

    cupertino_icons: ^0.1.3

    fluttertoast: ^7.0.1

  2. 在我的Dart文件中导入

    import 'package:fluttertoast/fluttertoast.dart';

到目前为止,它按预期运行。但是,当我转移到真实的iOS设备(我的iPhone XS)时,它无法编译。我得到了这个错误:

fatal error: module 'fluttertoast' not found @import fluttertoast;

我错过了什么?
5个回答

5
我最近遇到了这个问题,解决方法是这样的。我将pod文件的最小部署更改为11,因为我使用的一些包(如flutter stripe)需要这样做。但问题在于,在Xcode中,部署设置为9.0(未更改为11.0)。这导致问题无法解决,请按照以下步骤解决问题。
1:删除/iOS/podfile.lock(如果有)。
2:转到/iOS/podfile(platform:ios,'9.0'),将9.0替换为您的软件包/应用程序所需的版本。

enter image description here

3:在终端中输入cd ios (pod install)。

4:同时在Xcode中编辑部署信息版本。

enter image description here

第五步:运行应用程序,如果构建存档,则不会抛出错误。


5

令人惊讶的是,我刚刚让它工作了。

我所做的:

  1. 尝试修改podfile文件。
  2. 运行出错,由于podfile文件导致。
  3. 将podfile文件恢复到原始状态。
  4. 尝试构建,弹出一个类似“你想使用Xcode版本还是磁盘上的版本”的对话框(之前我使用的是Xcode版本,可能导致了问题)
  5. 我选择使用磁盘上的版本。
  6. 程序现在可以在真实的iOS设备上运行。

所以,每当您遇到弹出对话框询问“要使用哪个版本”时,请始终选择“磁盘上的版本”。

谢谢大家


1
今天我遇到了同样的问题,我的做法是切换到项目ios文件夹,运行以下命令:
pod repo update
pod install

从日志输出中,我们可以发现该Pod安装了fluttertoast依赖项:

➜  ios git:(master) ✗ pod install
Analyzing dependencies
Downloading dependencies
Installing FMDB (2.7.5)
Installing Flutter (1.0.0)
Installing SwiftAudioEx (0.14.7)
Installing Toast (4.0.0)
Installing device_info_plus (0.0.1)
Installing flutter_secure_storage (3.3.1)
Installing fluttertoast (0.0.2)
Installing in_app_purchase_ios (0.0.1)
Installing music_player (0.0.1)
Installing path_provider_ios (0.0.1)
Installing shared_preferences_ios (0.0.1)
Installing sqflite (0.0.2)
Installing system_clock (0.0.1)
Installing url_launcher_ios (0.0.1)
Installing video_player_avfoundation (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 12 dependencies from the Podfile and 15 total pods installed.

[!] 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`).

然后在Xcode中成功构建该项目。

0
  1. 我删除了podfile.lock文件
  2. 我只是注释掉了 platform :ios, '11.0' enter image description here
  1. 然后我运行了pod install命令

0

这对我有用

Open -> ios -> Podfile

取消注释该行代码。
#platform :ios, '11.0'
//to
platform :ios, '11.0'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接