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

Sam*_*mel 10 xcode ios 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

Run Code Online (Sandbox Code Playgroud)

这是我的 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'
Run Code Online (Sandbox Code Playgroud)

我变得很痛苦,因为我花了两天时间观看 YouTube 视频,查看我能查看的任何文章,而且,我没有骗你,没有任何效果。我什至联系了 Firebase 支持以获得一些答案,但我还没有得到任何回应。

如果您碰巧知道我如何解决这个问题,我将非常感激!

小智 6

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

  1. 删除Podfile、Podfile.lock、Pods文件夹
  2. 扑干净
  3. 光盘
  4. pod deintegrate (这样 pod 就不会重新安装旧的库)
  5. 光盘 ../
  6. 扑腾跑

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


小智 3

你缺少 firebase_core

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.5.0
  cloud_firestore: ^0.14.0+2
Run Code Online (Sandbox Code Playgroud)

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