Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter on IOS: fatal error: module 'cloud_firestore' not found

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

like image 798
Lab Avatar asked Oct 14 '20 22:10

Lab


2 Answers

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
like image 135
ValiSpaceProgramming Avatar answered Oct 04 '22 05:10

ValiSpaceProgramming


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.

like image 29
bybyby Avatar answered Oct 04 '22 05:10

bybyby