致命错误:找不到模块“ cloud_firestore”

时间:2020-09-22 18:22:45

标签: ios xcode firebase flutter google-cloud-firestore

每次尝试将Cloud Firestore添加到Flutter项目时,都会出现此错误。我首先在我的主项目中尝试过,但失败了。我在一个干净的新项目上进行了尝试,每次都能得到相同的结果。我读过至少10条不同的帖子,其中有人遇到此错误。没有一个起作用。我尝试删除Pods和Podfile / Podfile.lock并生成新的。我尝试使用最新的依赖项“ cloud_firestore:^ 0.14.0”。


这是我的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


这是我的Podfile(部分):

# 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'

我很痛苦,因为我已经花了两天时间观看YouTube视频,检查了我可以找到的任何文章,但我不告诉你,没有任何效果。我什至已经联系了Firebase支持以获得一些答案,但是我还没有得到任何答复。

如果您碰巧知道如何解决此问题,我将非常感谢!

3 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。在连接的iOS设备上本地运行时可以正常工作,但是当我使用flutter build ios时,会遇到同样的错误。希望有人可以帮助解决此错误。

答案 1 :(得分:1)

您缺少firebase_core

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

查看此官方指南以了解更多信息:Cloud Firestore

答案 2 :(得分:1)

  1. 用这个替换你的 podfile
<块引用>

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
  1. flutter clean
  2. flutter run