21

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
  • 1,237
  • 2
  • 13
  • 30
  • 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 Filipe Medeira 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

19 Answers19

30

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
  • Vail, this might be a stupid question, but I'm coming from Android, and I don't `podspec.yaml` file. I have a `pubspec.yaml` in my flutter app root and a `flutter.podspec` in my ios/flutter/ directory. I'm currently getting the same error as OP, so I'm trying to work through this. – Powermaster Prime Oct 02 '22 at 02:19
  • I ran your code anyway, and it seemed to have partially installed, but ran into this warning/error ` [!] CocoaPods could not find compatible versions for pod "Flutter": In Podfile: Flutter (from `Flutter`) wakelock (from `.symlinks/plugins/wakelock/ios`) was resolved to 0.0.1, which depends on Flutter Specs satisfying the `Flutter (from `Flutter`), Flutter` dependency were found, but they required a higher minimum deployment target. ` Any advice on how to proceed? – Powermaster Prime Oct 02 '22 at 02:26
  • Worked like a charm in 2023 March – Elmar Mar 02 '23 at 12:30
27

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
  • 271
  • 3
  • 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
  • 216
  • 2
  • 7
4

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
  • 17,235
  • 8
  • 110
  • 131
4

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,442
  • 2
  • 40
  • 65
1

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
  • 874
  • 1
  • 8
  • 9
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

In my case, I have a Mac with Apple Chip, so I have to run pod install with arch -x86_64

So... first configure your platforms, and follow the instructions

flutterfire configure --project=...

Then, add the Firebase Core libraries

flutter pub add firebase_core

Run "flutter run" it will fail

flutter run

So, go to ios folder

cd ios

Edit Podfile and change "platform :ios, '9.0'" to "platform :ios, '11.0'" (or higher)

Then execute

arch -x86_64 pod install --repo-update

And then

flutter run

PatricioS
  • 111
  • 8
1

I have watched several solutions & now I have got the answer why this is happing.

You can solve this issue in 1 minute.

Just add those lines on Podfile:

target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.4.0' // you have to add this line
  ...
  ...
  ...
  ...
end

I am using tag version: '9.4.0'. You might need to change this as per you using firebase cloud storage.

Just boom. You solve the problem !!!

Md. Al-Amin
  • 690
  • 3
  • 13
1

Your issue not may be a big situation. You might be opening the wrong file in the wrong folder.

So, check out from which folder you are opening in Xcode as Runner.xcworkspace.

You need to from Runner.xcworkspace folder not Runner.xcodeproj.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
algor
  • 67
  • 2
0

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
  • 554
  • 1
  • 8
  • 29
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,953
  • 5
  • 49
  • 80
  • 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
0

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,458
  • 10
  • 44
  • 49
0

None of the answers worked for me so I am adding the one that did.

  1. Replace the contents of your Podfile with the following.
platform :ios, '12.0'

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

def flutter_install_ios_plugin_pods(ios_application_path = nil)
  ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
  raise 'Could not find iOS application path' unless ios_application_path

  symlink_dir = File.expand_path('.symlinks', ios_application_path)
  system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils.

  symlink_plugins_dir = File.expand_path('plugins', symlink_dir)
  system('mkdir', '-p', symlink_plugins_dir)

  plugins_file = File.join(ios_application_path, '..', '.flutter-plugins-dependencies')
  plugin_pods = flutter_parse_plugins_file(plugins_file)
  plugin_pods.each do |plugin_hash|
    plugin_name = plugin_hash['name']
    plugin_path = plugin_hash['path']
    if (plugin_name && plugin_path)
      symlink = File.join(symlink_plugins_dir, plugin_name)
      File.symlink(plugin_path, symlink)

      if plugin_name == 'flutter_ffmpeg'
          pod 'flutter_ffmpeg/full-lts', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
      else
          pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
      end
    end
  end
end

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
  1. Run pub get
  2. Run pod install
Safi50
  • 379
  • 1
  • 7
0
  1. Replace the contents of your Podfile with the following.

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
    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
0

after a while i found out the solution and its quite simple, for anyone who trying to archive and upload flutter app to app store and having the issue of not detecting the Firebase modules please follow these steps:

note: if you have been already trying and you have created podFiles or plist files like google-services.plist please remove them all and start over...

1- make sure when you use mac device that you install flutter SDK and all the necessary tools (VSCode, git, Cocoapods) in case you are using it only for deployment.

2- after setting up your mac device for flutter development open your files on VSCode and leave it open.

3- open XCode and select open a project or file and select the ios folder, or you can open XCode then return to VSCode and right click (Control + Click) on the ios folder and select "open with XCode".

4- go to your Firebase console and open your project, if you have already set-up your project with IOS click on the IOS project and scroll down to find "Download google-services.plist", Otherwise please setup your project for IOS by only installing google-services.plist file and skip the other steps.

5- go to your Downloads or the place that you downloaded the plist file on and drag it to your XCode under the bottom runner folder where your "info" file exist.

6- go to VSCode now and and open the terminal and type cd ios.

7- This step is the magic, on your terminal type flutter pub get, and you will see an auto podFile generated on your ios folder !.

8- now type pod install and congratulations all pods and dependencies for Firebase are installed correctly.

9- Close XCode and re-open it choosing the ios folder you will notice a change on the files structure.

10- from products tap above choose destination to "any ios device" then Archive.

have a good day !

editix
  • 322
  • 2
  • 14
0

For my case I just changed the pod file platform ton 12.0 and the Xcode platform to 12.0. This is after adding the following code to pod file

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['ENABLE_BITCODE'] = 'NO'
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
           end
  end
end
Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39
0

I had the same problem and none of the solutions seems to work : this is my solution that worked : (in the ios directory do all the following )

  1. pod cache clean --all
  2. pod deintegrate
  3. sudo gem install cocoapods-deintegrate cocoapods-clean
  4. sudo arch -x86_64 gem install ffi
  5. arch -x86_64 pod repo update
  6. arch -x86_64 pod install
cigien
  • 57,834
  • 11
  • 73
  • 112