15

After searching long hours on github and stack for similar errors, none of the proposed solutions helped me to resolve this error.

I tried quite a few things (a bit out of order):

  • remove IOS derived data
  • change firestore package version
  • flutter clean
  • rm -Rf ios/Pods
  • rm -Rf ios/.symlinks
  • rm -Rf ios/Flutter/Flutter.framework
  • rm -Rf ios/Flutter/Flutter.podspec
  • rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace
  • pod init, install and update
  • uncomment platform :ios, '9.0' from podfile (maybe not linked to this issue)

Here is the error:

    ** BUILD FAILED **


Xcode's output:
↳
    /Users/flo/Mobile/we_ll_see/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module
    'cloud_firestore' not found
    @import cloud_firestore;
     ~~~~~~~^~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Need some help guys

Lab
  • 947
  • 2
  • 10
  • 24
  • I had a problem similar to this one today, in xcode he said that a module was missing, but when I build the project in android studio to run on the ios emulator, it gave a different error, there was an error in info.plist. Try to compile through android studio, maybe it will help you. – Luiz Oct 14 '20 at 23:47
  • I got the exactly same error and Android Studio – Lab Oct 15 '20 at 08:29
  • Can you add a snippet of your `Podfile` inside ths `ios/` folder of your flutter project. And also can you try building this app from `xcode` that might give you some better logs. – yusufpats Nov 03 '20 at 03:26
  • which version of firebase_core and cloud_firestore are you using? – victwise Nov 03 '20 at 04:58

11 Answers11

23

this is a very bad and unlucky error. After trying to solve this issue for hours, i finally found the solution. The problem is, that your Podfile isn't updating with the pubspec.yaml file. I think, that your Podfile is nearly empty:

target 'Runner' do
 use_frameworks!

end

But thats a big problem. This Podfile will be created if you try: $ rm Podfile and then $ pod init.

Here is my solution:

... but before, you have to check something, otherwise my solution probably won't work: RUN:

$ pod install

If the result of this command is:

There are 0 dependencies from the Podfile and 0 total pods installed.

You can be sure, that this solution works. Otherwise it will also function but maybe you should write me your result of the command line in the comments!!

Now back to the solution...

  1. Step: Update your Podfile with the following code (Please delete the old stuff of the file):

     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
    

Now the Podfile is updating the pods you wrote down in your podspec.yaml file.

Now you have to sync you podspec.yaml file with the xcode pods, by calling:

$ pod install

Then you will see all you pods downloading. After this you can run your flutter project, by calling flutter run or just in your editor.

Note: The Podfile.lock file lists down the pods and versions of each pod. The 'real' Podfile is only used for the connection between the podspec.yaml file and the real pods. If you look at your Podfile.lock file, you will see, that there aren't any pods written down and that's causing the problem. If there aren't any pods to install, each module (e.g. 'cloud-firestore') won't be found...

I hope this answer helps you, you can ask me in the comments if something didn't work, but i know, that this won't happen :)

Edit for macos:

platform :osx, '10.11'
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', 'ephemeral', 
'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 Flutter- 
Generated.xcconfig, then run \"flutter pub get\""
end

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

flutter_macos_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_macos_build_settings(target)
  end
end
  • 1
    Yeah I was having this problem because I was manually generating the podfile because of this error: https://stackoverflow.com/questions/64397478/flutter-uialertview-is-deprecated-first-deprecated-in-ios-9-0. So I fixed this problem and xcode was able to find the modules. – Lab Nov 05 '20 at 12:10
  • I'm getting this message after running `pod install' inside ios folder. Pod installation complete! There is 1 dependency from the Podfile and 10 total pods installed. – ASAD HAMEED Jan 15 '21 at 09:30
  • perfect, worked for me. ios 14.5 iphone 12 pro, – Raiden Core Jun 04 '21 at 14:58
15

For me I just update deployment target to the same as define in Pod file.

Note you need to open Runner.xcworkspace not Runner.xcodeproj.

bybyby
  • 151
  • 1
  • 2
7

If you are using Android Studio the error might occur if you are creating the Podfile manually. Flutter runs using just the pubspec.yaml file. You don't have to set up the Podfile by yourself. If you follow the installation guideline on the firestore homepage just skip everything after adding GoogleService-Info.plist file using Xcode.

jpheine
  • 196
  • 1
  • 7
3

I tried

rm Podfile  
pod init
pod install

but it always showed installed 0 dependencies

then I deleted

podfile.lock

and tried

pod install again

and it installed all project dependencies including cloud_firestore. and flutter run and flutter build ios worked.

Mahesh Jamdade
  • 11,710
  • 4
  • 79
  • 97
1

Make sure you are placing the google services info plist file which you download from firebase into as same folder as info-plist

1

Remove cocoapods entirely by

sudo gem install cocoapods-deintegrate cocoapods-clean

pod deintegrate

pod clean

rm Podfile

deleting the Podfile/Podfile.lock

Then simply run

flutter run
1

I also faced the same issue and I tried all the solutions above but none of them worked. Then I tried the following steps and it works.

flutter channel dev
flutter upgrade
flutter run
chk.buddi
  • 507
  • 1
  • 6
  • 21
1

Well, in my case the issue was the deployment target. It seems that the default deployment target is 9.0 and Firestore requires a higher deployment target.

I updated my Podfile platform ios, '10.0'

Also in Xcode, from the build settings of the runner project, I changed the deployment target to ios 10.

That worked for me.

MSaudi
  • 4,012
  • 2
  • 36
  • 61
0

Sharing this in case it helps someone else in the future. I had the same issue as the original poster. I tried all of the solutions suggested above and none of them worked for me. As of the writing of this message, at least 5 different people have reported the same issue in the flutterfire repo on Github but no one has posted a clear solution there either.

What did work for me was deleting the entire ios directory in my Flutter project, then rebuilding it:

flutter create -i swift .

It was very time consuming, but it solved the issue. The 'cloud_firestore' not found error is no longer occurring for me. In addition to rebuilding the ios folder, I had to re-add GoogleService-Info.plist to Runner, re-add icons, re-add signing & capabilities in Xcode, and re-add target properties in Xcode such as privacy usage descriptions, etc.

I'd recommend trying all of the other options mentioned above first, but if like me they do not solve the issue for you, deleting and rebuilding the entire ios folder may be an effective next step.

most200
  • 401
  • 1
  • 4
  • 8
0

, my previous answer was unclear. This was just one of many errors I've got while trying to set up Cloud Firestore, so I didn't go through the whole process.

In order for firebase to work, eventually, you have to follow all of the steps from this page: https://firebase.flutter.dev/docs/firestore/overview/

If you are having problems with generating the firebase_options.dart file, then you need to follow the steps on this page: https://firebase.google.com/docs/cli#mac-linux-auto-script

The last step is optional, but it reduces build time, and I really don't know how or why, but it made some of the other errors also disappear...

Step 4. Improve iOS & macOS build times, from this page https://firebase.flutter.dev/docs/firestore/overview/

And of course, don't forget to add dependencies in pubspec.yaml

Ref: https://pub.dev/packages/firebase_core/install

There is also a great comment here about using Firebase.initializeApp()

Ref: https://stackoverflow.com/a/63492262/17626190

CodeChanger
  • 7,163
  • 4
  • 41
  • 74
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '21 at 16:24
-1

For anyone still facing this error, the following worked for me:

I was facing the exact same error. My pod file looked exactly like the one asked in the question

target 'Runner' do
  use_frameworks!

 end

I solved by doing the following:

  1. Delete the ios folder

  2. in the main directory, run the following

    flutter create .

This will generate a new ios folder.

  1. run flutter clean
  2. run flutter pub get
  3. cd ios/ and run pod install

That should install all the pods properly in your ios project now.

ouflak
  • 2,408
  • 10
  • 40
  • 47