【问题标题】:fatal error: module 'firebase_core' not found致命错误:找不到模块“firebase_core”
【发布时间】:2020-05-11 22:56:23
【问题描述】:

刚刚创建了一个新的 Flutter 项目,将 google-services-info.plist 文件添加到 iOS 并将 firebase_core 添加到 pubspec.yaml。运行项目并收到此错误。 Error: fatal error: module 'firebase_core' not found @import firebase_core;

我在堆栈溢出和gitlab上搜索了很多。尝试了所有解决方法,例如flutter clean、更新 repo、删除 pod 和重新安装 pod,但仍未成功解决此错误。

这已阻止我 5 天。在这方面找不到任何东西。 请帮忙。

链接到我在 GitHub 上的项目。 :https://github.com/infonotics/stocklyticsSO 将您自己的 googleService-Info.plist 文件添加到 Runner 文件夹。出于安全原因,我删除了我的文件。

提前致谢。

【问题讨论】:

  • 您好,您解决了这个问题吗?

标签: ios flutter flutter-dependencies


【解决方案1】:

在 XCode 中打开项目时,请确保打开扩展名为 .xcworkspace 的文件,而不是扩展名为 .xcodeproj 的文件,然后重新构建。

【讨论】:

  • 你拯救了我的一天 :)
【解决方案2】:

如果打开 xcode 时出现任何错误,请忽略它并执行以下步骤。 错误类型:在 GeneratedPluginRegistrant.m 处未找到任何模块 firebase..(在我的情况下,未找到 firebase_core))

1.0.flutter clean(VS 代码)

2.0.flutter pub 获取(VS 代码)

3.0.打开ios模拟器(VS Code)

4.0. 颤振运行(VS 代码)

5.0编译完成

6.0.关闭模拟器

6.0. 使用 xcode (XCODE) 打开 ios 文件夹

7.0. 确保在此期间选择了 iphone SE(第 2 代)或任何设备 编译(XCODE)

8.1.开始编译(XCODE)

9.2 错误消失了。

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

【讨论】:

    【解决方案3】:

    在你的 Flutter 应用的 ios 文件夹中运行 pod install

    1. 打开终端
    2. cd "你的项目"/ios
    3. 吊舱安装

    【讨论】:

      【解决方案4】:

      我遇到这个问题 3 天,然后我发现根本原因是 我在M1上跑步 所以在关注link

      之后我的错误得到了解决

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      【解决方案5】:

      您需要下载并更新 Podfile 中的包。

      1. 打开终端
      2. cd ./ios
      3. pod 更新

      【讨论】:

        猜你喜欢
        • 2021-08-08
        • 2021-01-08
        • 2020-06-22
        • 2022-01-16
        • 2021-09-07
        • 2021-05-24
        • 2021-06-15
        • 2020-04-22
        • 2016-10-14
        相关资源
        最近更新 更多