致命错误:找不到模块"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

这是我的播客文件(部分(:

# 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支持部门以获得一些答案,但我还没有得到任何回应。

如果你碰巧知道我该怎么解决这个问题,我会非常感激的!

相信我,我搜索了5个多小时,尝试了在互联网上找到的所有解决方案。只有一项工作:

  1. 删除Podfile、Podfile.lock、Pods文件夹
  2. 颤振清理
  3. cd ios
  4. pod解集成(这样pod就不会重新安装旧库(
  5. cd/
  6. 颤振运行

大多数解决方案都不包括步骤4,所以即使您清理并重新安装pod,它的行为仍然相同。在开发人员那里,我们可以在2小时内学习如何反转二进制树,并在一天多的时间里与安装步骤作斗争,这是开发人员最烦人的事情之一。

您缺少firebase_core

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

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

  1. 用这个文件替换您的podfile

ENV['OCOAPODS_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

最新更新