Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: module 'cloud_firestore' not found

I get this error every time I try adding Cloud Firestore to my Flutter project. I first tried it with my main project, where it failed. I tried it on a clean new project where I get the same result every single time. I've read at least 10 different posts where someone had this error. None of it has worked. I tried deleting Pods and Podfile/Podfile.lock and generating new ones. I've tried using the newest dependency "cloud_firestore: ^0.14.0".


This is my pubspec.yaml:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:

  cloud_firestore: ^0.14.0

  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter


This my Podfile (part of it):

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

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

  # Pods for Runner

end

# add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods

pod 'Firebase/Firestore'

I am getting miserable because I've spent two days watching YouTube videos, checking any article I could and, I kid you not, nothing has worked. I've even contacted Firebase Support to get some answer, but I haven't gotten any response yet.

If you happen to know how I could fix this, I will seriously be so thankful!

like image 670
SamuelHrmel Avatar asked Sep 22 '20 18:09

SamuelHrmel


3 Answers

Trust me, I search for over 5 hours, tried every solution I can find on internet. And only one work:

  1. Delete the Podfile, Podfile.lock, Pods folder
  2. flutter clean
  3. cd ios
  4. pod deintegrate ( this way pod will not reinstall the old libray )
  5. cd ../
  6. flutter run

Most of the solution don't include step 4, so that why even you clean and reinstall pod, it still behave the same. At the developer, we can learn how to reverse the binary tree in 2 hour and struggle with install steps for over a day, one of the most annoying thing of being developer.

like image 130
Trong Tran Avatar answered Nov 20 '22 01:11

Trong Tran


you are missing firebase_core

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.5.0
  cloud_firestore: ^0.14.0+2

check this official guide for more: Cloud Firestore

like image 27
Besufkad Menji Avatar answered Nov 20 '22 01:11

Besufkad Menji


  1. replace your podfile with this one

ENV['COCOAPODS_DISABLE_STATS'] = 'true' //add this line at the beginning of that file

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
    platform :ios, '9.0'
    target 'Runner' do
      use_frameworks!
      use_modular_headers!
      pod 'Firebase/Core'
      pod 'Firebase/Firestore'
      pod 'Firebase/Analytics'
      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
  1. flutter clean
  2. flutter run
like image 1
Ali Alsamraay Avatar answered Nov 20 '22 00:11

Ali Alsamraay