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

时间:2020-01-26 07:21:11

标签: ios flutter flutter-dependencies

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

我在堆栈溢出和gitlab上进行了大量搜索。尝试了所有变通方法,例如清理干净,更新存储库,删除Pod并重新安装Pod,但仍然无法成功解决此错误。

这已封锁了我5天。在此上找不到任何东西。 请帮忙。

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

谢谢。

3 个答案:

答案 0 :(得分:1)

如果在打开 xcode 时出现任何错误,请忽略它并执行以下步骤。 错误类型:GeneratedPluginRegistrant.m)

1.0.flutter clean(VS Code)

2.0. flutter pub get (VS Code)

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

4.0. flutter run (VS Code)

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

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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

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