ios - IOS : fatal error: module 'cloud_firestore' not found 上的 flutter

标签 ios firebase flutter google-cloud-firestore

在 github 和 stack 上搜索了很长时间以查找类似错误后,没有一个建议的解决方案可以帮助我解决此错误。
我尝试了很多东西(有点乱):

  • 删除 IOS 派生数据
  • 更改 Firestore 软件包版本
  • flutter 干净
  • 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 初始化、安装和更新
  • 取消注释平台 :ios, '9.0' from podfile (可能没有链接到这个问题)

  • 这是错误:
        ** 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
    
    需要一些帮助

    最佳答案

    这是一个非常糟糕和不幸的错误。在尝试解决这个问题几个小时后,我终于找到了解决方案。问题是,您的 Podfile 没有使用 pubspec.yaml 文件进行更新。我认为,您的 Podfile 几乎是空的:

    target 'Runner' do
     use_frameworks!
    
    end
    
    但这是个大问题。如果您尝试: $ rm Podfile 然后 $ pod init 将创建此 Podfile。
    这是我的解决方案:
    ...但在此之前,您必须检查一些内容,否则我的解决方案可能无法正常工作:
    跑:
    $ pod install
    
    如果此命令的结果是:
    There are 0 dependencies from the Podfile and 0 total pods installed.
    
    您可以肯定,此解决方案有效。否则它也会起作用,但也许你应该在评论中写下你的命令行结果!
    现在回到解决方案...
  • 步骤:使用以下代码更新您的 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
    
     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.


    现在您必须通过调用将 podspec.yaml 文件与 xcode pod 同步:
    $ pod install
    
    然后你会看到你所有的 pod 都在下载。在此之后,您可以通过调用 flutter run 或仅在您的编辑器中运行您的 Flutter 项目。
    注意:Podfile.lock 文件列出了 pod 和每个 pod 的版本。 'real' Podfile 仅用于 podspec.yaml 文件和真实 pod 之间的连接。如果您查看您的 Podfile.lock 文件,您会看到,没有任何 pod 被记录下来,这就是问题所在。如果没有要安装的 pod,则不会找到每个模块(例如“cloud-firestore”)...
    我希望这个答案对您有所帮助,您可以在评论中问我是否有问题,但我知道,这不会发生:)
    为 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
    

    关于ios - IOS : fatal error: module 'cloud_firestore' not found 上的 flutter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64362285/

    相关文章:

    ios - 核心动画 - 组中动画的单独计时

    ios滚动后保持UITableViewCell布局

    ios - @supports 指令如何在 Safari iOS 中工作

    ios - 通过 Firebase 从 MapKit 注释转至 UITableViewCell

    flutter - Flutter 中使用@override 的目的是什么?

    ios - 字符串的静态 NSArray - 如何/在哪里初始化 View Controller

    swift - iOS 火力地堡 : Retrieve and match database code to pass through authentication

    python - Firebase 管理 SDK Python - 无法验证自定义 token

    flutter - rxDart 没有调用 onError

    flutter - 如何在 flutter 中使用 sharedpref 保存最大持续时间?