ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

Flutter Error on Real iOS Device: "module 'fluttertoast' not found"

My flutter app is working properly in iOS Simulator.

I have added fluttertoast by:

  1. Adding it on pubspec.yaml

    dependencies: flutter: sdk: flutter

    cupertino_icons: ^0.1.3

    fluttertoast: ^7.0.1

  2. Importing in my dart file

    import 'package:fluttertoast/fluttertoast.dart';

So far it works as intended. BUT, when I move to a REAL iOS device, my iPhone XS, It won't compile. I get this error:

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

What am I missing?

Upvotes: 6

Views: 12940

Answers (6)

Elijah Masanga
Elijah Masanga

Reputation: 1

Instead of opening Runner.xcodeproj you have to open Runner.xcworkspace then it will work

Upvotes: 0

Rahul Raj
Rahul Raj

Reputation: 1493

This worked for me

Open -> ios -> Podfile

Un-comment the line

#platform :ios, '11.0'
//to
platform :ios, '11.0'

Upvotes: 1

SAHIL SHARMA
SAHIL SHARMA

Reputation: 41

  1. I Deleted podfile.lock
  2. I Just Commented platform :ios, '11.0' enter image description here
  1. Then I Run pod install

Upvotes: 1

Dolphin
Dolphin

Reputation: 38763

Today I am facing the same problem, what I do is switch to the project ios folder, run this command:

pod repo update
pod install

from the log output, we can found the pod install the fluttertoast dependencies:

➜  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`).

then build the project in xcode success.

Upvotes: 1

Zakria Khan
Zakria Khan

Reputation: 2186

I have face this issue very recently and the way I fix is like this. I change the pod file min deployment to 11 as needed by some of the pacakges I was using like flutter stripe. but the issue was that in Xcode the deployment was set to 9.0(not changing to 11.0). which was causing the issue to fix the issue follow the step.

1 : delete to /iOS/podfile.lock (if any)

2 : go to /iOS/podfile (platform :ios, '9.0') replace the 9.0 with version required for your packages/app.

enter image description here

3 : in terminal cd ios (pod install)

4 : edit the deployment info version here as well in Xcode

enter image description here

5 : run the app it will work if building archive build archive it will not throw the error.

Upvotes: 5

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

Suprisingly, I made it work just now.

What I did:

  1. Tried to modified the podfile.
  2. Tried to run it. Error due to podfile.
  3. Revert podfile to original state.
  4. Tried to build, pop-up asking something like 'would you like to use Xcode version or version on disk (I used Xcode version before which may have caused the problem)
  5. I chose to use VERSION ON DISK.
  6. Program is now working on real iOS device.

So whenever you get the pop-up asking "which version to use", always choose "VERSION ON DISK".

Thanks guys

Upvotes: 6

Related Questions