Flutter module not found in Xcode
Asked Answered
S

28

86

When I build the app in Xcode it throws the error: .../ios/Runner/GeneratedPluginRegistrant.m:10:9: Module 'audioplayers' not found I tried reinstalling and setting up pods again, however it didn't work. I am also including pod 'Firebase/Core' in the pod file. Maybe I need to include the Audioplayer module there as well? Thanks in advance!

Systaltic answered 22/5, 2020 at 13:26 Comment(1)
you can also check this answer just in case if it's not resolved https://mcmap.net/q/243434/-flutter-plugin-project-build-breaks-import-module-not-found-for-ios In my case, I was opening ios/Runner.xcodeproj instead of ios/Runner.xcworkspaceBroom
D
153

Make sure platform: iOS version in pod file matches with deployment info in Xcode

enter image description here

Disciplinarian answered 8/7, 2021 at 10:8 Comment(3)
Thanks! This fixed the issue for me. I had XCode Build Settings on Runner project as follows: Project Runner -> Build Settings -> Deployment -> iOS Deployment Target: iOS 9.0 My podfile said: platform :ios, '13.0' I changed my XCode build settings to 13.0 and ran flutter build ipa and it worked.Spongioblast
I tried changing this, but nothing would work. In the end, what worked was deleting and re-creating the entire ios folder, and then setting the above value to 9.0Uterus
Thanks, this solved for me. Had to flutter clean, remove Pods and Podfile and run pod install after changing the version in Xcode and in the Podfile.Brena
M
109

Did you make sure that you started xcode by double clicking the "runner.xcworkspace" from your "project/ios" folder and not "runner.xcodeproj"?

According to this source, it solves the "missing module" issue for a lot of people (As it did for me). https://github.com/flutter/flutter/issues/41033

Manumit answered 5/8, 2021 at 17:4 Comment(0)
F
37
  1. Delete Podfile
  2. flutter clean
  3. flutter pub get
  4. flutter build ios

It works for me!

Folberth answered 21/6, 2021 at 20:41 Comment(1)
omg..doing this, I was able to archive and deploy to testflight/App Store...Greenlet
P
21

Make sure that the selected scheme to run is "debug"

  • Click "Runner" which is just near the simulator dropdown.
  • Edit scheme.
  • Select "Run" at the left list.
  • Select "Debug" for "Build Configuration"
Pademelon answered 18/10, 2021 at 12:2 Comment(2)
This was my problem, ( none of the other stuff worked ), thank you.Thapsus
Thank you so much! I was having a problem when archiving my production flavor. Turns out archive was Release, instead of Release-production.Nonsuch
M
18

I got same error with Better Video Player. Make sure your IOS Version in Pod File is 11. 1st make sure you are opening runner.xcworkspace If issue is still present then try this step.

1.- flutter clean
2.- flutter pub get
3.- cd ios
4.- pod deintegrate
5.- pod install

If issue is still present then

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
    end
  end
end
Meerschaum answered 31/12, 2021 at 5:29 Comment(1)
I think the problem is about having a lot of libraries of different targets (lower than the one defined as the target for the project). Doing this: config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '[same target defined in podfile and xcode]' is the key. Thanks for helping us.Triumvirate
D
14

Have tried many things, flutter clean, revert the Podfile and etc, still facing the same issue.

Eventually get this fix by solving the issue highlighted in Xcode. You can check

https://github.com/flutter/flutter/issues/54599#issuecomment-644336055 https://github.com/flutter/flutter/issues/53573#issuecomment-749912604

Desiccator answered 23/12, 2020 at 3:49 Comment(0)
P
10

For me (Mac w/ M1) I ran the following:

  1. flutter pub get
  2. cd ios
  3. rm -rf Pods/ Podfile.lock
  4. pod install

After this, running application within xcode worked as expected.

Patrilineal answered 28/10, 2021 at 8:39 Comment(0)
B
9

On mac with m1

1.- Delete Podfile

In Android Studio:

2.- flutter clean
3.- flutter pub get
4.- cd ios
5.- pod install

An then

6.- Build and run your app through Xcode

this worked for me.

Blackstone answered 6/10, 2021 at 0:42 Comment(1)
also set minimum iOS version to 12 and Swift by 5, guide here #56894582Injurious
A
8

Try this simple steps it worked for me

  1. Delete pod directory and podfile.lock

  2. flutter clean

  3. flutter pub get

  4. cd ios

  5. pod install --repo-update

  6. run the application in Xcode

Airboat answered 17/5, 2022 at 8:2 Comment(0)
P
6

I had a similar issue with the following compiler output:

/Users/me/flutter_project/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'barcode_scan' not found
    @import barcode_scan;
     ~~~~~~~^~~~~~~~~~~~

My project contains multiple build environments with Flutter flavors as described here: https://medium.com/@thomasgallinari/e7a0c973f54e

What solved the issue for me is changing the casing of the build configurations and the corresponding files from values like Debug-stage to Debug-Stage as the latter is expected by Flutter.

Paperback answered 26/10, 2020 at 14:24 Comment(1)
This worked for me. I had this same issue with amplify_flutter, built and ran fine from xcode but wouldn't run debug builds from flutter command line (flutter run --flavor dev). Saved my sanity, thank you!Machicolate
M
6

If you run the program through Xcode, make sure that you have opened the Runner.xcworkspace file in XCode, not the Runner.xcodeproj file

Monahan answered 6/12, 2021 at 7:15 Comment(1)
This happens so easily!Galleon
N
4

Nothing worked in my case. I was able to run the project from VSCode but I couldn't archive on XCode. I've solved via choosing the scheme.

Yes, scheme. This project have 3 different flutter flavors, a.k.a iOS schemes. I realized I can't even list the devices or simulators for this project. Issue was, I didn't choose the scheme instead of it was on default one, Runner.

By nothing, I mean everything. I've deleted podfile, podfile.lock, I've changed deployment targets, I've deleted pods folder, I've added post scripts to update dependencies to 9.0, I've tried flutter clean and pod install --repo-update.

Issue simply was not choosing the right scheme.

Nonsuch answered 3/10, 2021 at 16:13 Comment(2)
This was my issue. though i follow the process like delete pod > flutter pub get > cd ios > pod install Then In XCode > clean build > Select RIght Build Flavor (Production For Me) > then Archive.Seismology
I cannot belive it. I did all the things, I've deleted podfile, podfile.lock, I've changed deployment targets, I've deleted pods folder and so on. I just had to go to Product > Scheme > Edit Schema (2x) > Change Build Configuration to DebugQuatre
R
4

Hello if you try all the ways above and can't solve your problem you can check. on your Scheme -> Edit Scheme... -> Build Configuration

In Build Configuration select box => check your config name is the right config you have. In some cases it's missing the "-" character and you need choose the right config.

Then close and rebuild your project.

Rag answered 2/1, 2022 at 16:58 Comment(0)
R
2

I have tried many things like delete the pod file and podfile.lock, flutter clean, reinstall cocoa pods, changing scheme, but nothing worked for me until I tried to change different version numbers (Ex: 8, 9 etc.) And finally when I changed from 8 to 10 (platform :ios, '10.0') in Pod file it worked. I think some libraries are not supporting some platform versions. For my project 10th worked. If you have the same problem try to change different platform :ios versions in podfile one by one, hope this will help.

NOTE: The platform :ios version in podfile should be same with the IOS Deployment Target in XCode -> Project Runner under Info tab otherwise it fails

Regulate answered 9/4, 2022 at 4:20 Comment(0)
K
2

If you tried everything but error still appears, make sure that your path to project doesn't contains whitespaces. Sometimes Xcode can't deal with it. And make sure that you have the latest Xcode and MacOS version.

Karmakarmadharaya answered 27/7, 2022 at 13:50 Comment(0)
G
2

You need to change the podfile to this, someone above also said to change the podfile.

ENV['COCOAPODS_DISABLE_STATS'] = 'true'
platform :ios, '9.0'
project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

Hopefully this will solve the module_not_found issue on Xcode, It worked for me and I was able to publish the app

Gosser answered 3/4, 2023 at 6:52 Comment(0)
M
1

go ios folder "cd ios" and run "pod install" and run again

Malfeasance answered 20/9, 2021 at 20:18 Comment(0)
F
1

That can happen if you use M1 Chip Mac and using older flutter versions, i had to install all pods using Rosetta. Go to terminal -> right click -> info -> use Rosetta.

Fiberglass answered 25/10, 2021 at 8:30 Comment(0)
L
1

in my case, it was an issue with the firebase, firestore document. just make sure to update all libraries, like firebasecore, firebaseauth, analytics, etc to the latest version.

why it is showing the error of audioplayers?

because it is stated at the first position among all libraries.

means there is no issue at my side for audioplayer. after updating all libraries I just install the app.

if you still face a problem make sure to flutter clean then pod install. then run the app.

yes sometimes codes run on android but not run on ios. for that you have to update the libraries.

Lagasse answered 9/12, 2021 at 9:0 Comment(0)
G
1

Make sure that ios version on podfile and development info be same

Gracchus answered 14/7, 2022 at 5:15 Comment(0)
P
1

in my case the Pods not downloaded, because of Cocoapods version is not suitable (i am using apple silicon but using arm Pods). Reinstall Pods and using the proper version.

First open terminal and do this

sudo arch -x86_64 gem install ffi

then move into folder IOS folder and run this

arch -x86_64 pod install
Preparatory answered 3/9, 2022 at 3:43 Comment(0)
A
1

I also ran into this problem when launching the app with the simulators. After trying all above methods, it is still not fixed. I used the cable and run the app with my phone. And it worked like a charm. I hope this helps.

Aftermath answered 7/9, 2022 at 10:14 Comment(0)
S
1

Make sure you open Runner.xcodeproj and not Runner.xcworkspace when using Xcode

Scutiform answered 20/2, 2023 at 8:7 Comment(0)
H
1

I had this problem because I tried to install a plugin flutter app_tracking_transparency while the app was running.

To fix, stop the app, remove the new plugin

flutter pub remove app_tracking_transparency

then add again

flutter pub add app_tracking_transparency

and voila, it works!

Harte answered 23/10, 2023 at 5:19 Comment(0)
L
0

In my case, without my knowledge, the Podfile was shortened a lot. The error that was popping up was:

module 'camera_avfoundation' not found

When comparing the commits with my old solution (when this problem wasn't occurring) this was the Podfile:

# ** OLD PODFILE **
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

And this was the shortened Podfile:

# ** NEW PODFILE **
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Runner

end

I have no idea how it got shortened, what caused it, but the only thing that changed between these two commits were adding these two libraries:

firebase_core: ^2.4.1
firebase_crashlytics: ^3.0.10

to the project's pubspec.yaml file.

After I saw the diff between these two files, I just overwrote the shorter Podfile with the longer one (from old commit), and everything went well. Hope someone can shed some light why/how this happened, and why deintegrating/cleaning Podfile did not help.

Leonteen answered 12/1, 2023 at 19:14 Comment(0)
B
0

Just add build number and build version in Xcode (Target->General->Identity)

Find the image

Biestings answered 19/5, 2023 at 13:6 Comment(0)
R
0

So, after spending about 5 hours on this issue I found a solution for myself. What I've tried was:

  • pod files and folder deletions
  • flutter cleanups
  • regeneating ios folder
  • Cleaning Xcode temp files
  • Setting different versions of ios
  • Reinstalling Xcode

Nothing has worked!

Finally I've realised the problem was with cocoapods version. I had a problem installing cocoapods earlier so I've used brew install cocoapods (instead of sudo gem install cocoapods) and it worked, however it caused all my later problems to come up.

Problem with installing cocoapods with sudo gem install was caused by outdated ruby version.

So the way to go for me was:

  • Update ruby (updated to 3.1.3 from 2.6.x) rvm install 3.1.3 this allowed to gem install cocoapods
  • Update cocoapods sudo gem install cocoapods
  • flutter clean
  • Delete pods folder, podfile, podfile.lock
  • flutter build ios
  • pod install after this, pods with modules should generate
  • Run with Xcode

Try my answer if you have installed cocoapods using homebrew/didnt update cocoapods or you dont have any pods depenedencies inside podfile.lock/no podfile.lock at all.

Retention answered 22/10, 2023 at 19:44 Comment(0)
P
0

None of the previous answer could solve my problem, but I found the fix for me:

I have changed many build settings in my xcode project, because of some special cases for my project. After all these changes, I forgot to add $(inherited) in "Header Search Path", "Framework Search Path", "Library Search Path" and "Other Linker Flags" to the build settings of my project.

So just add $(inherited) to all these fields and do pod install.

Pongid answered 5/3 at 9:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.