【问题标题】:flutter: fatal error: module 'firebase_analytics' not found颤振:致命错误:找不到模块“firebase_analytics”
【发布时间】:2021-06-15 12:21:23
【问题描述】:
在iOS上添加firebase依赖后,当我想运行时出现此错误
Xcode's output:
↳
../ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module
'firebase_analytics' not found
@import firebase_analytics;
~~~~~~~^~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the precompiled application for the device.
Error launching application on Abir's iPhone.
我已经尝试了很多方法。比如删除 pod 文件、更新 pod、安装 pod 等。
【问题讨论】:
标签:
ios
flutter
module
firebase-analytics
fatal-error
【解决方案1】:
打开 Runner 的问题。打开 Runner.xcworkspace 而不是 Runner.xcodeproj.
【解决方案2】:
我遇到了同样的错误,这里是解决方法。
- 从 Xcode 文件夹中删除 DerivedData。打开 Flutter 项目的 ios 文件夹中的 Runner.xcworkspace,然后单击 File -> Workspace Settings -> 单击 DerivedData 路径旁边的灰色箭头,然后删除 Xcode 文件夹中的 DerivedData。
- 删除 Flutter 项目的 ios 文件夹中的 Podfile 和 Podfile.lock 文件。
- 将部署目标更改为 12.0。您将在 General -> Deployment Info 下找到 Deployment Target。
- 清理您的 ios 构建文件夹。
- 运行您的应用程序(它将生成一个新的 podfile,不要编辑此 podfile)它应该可以工作。
【解决方案3】:
pod repo update 或pod install --repo-update
【解决方案4】:
我在 Catalina 上使用的是非常旧的 Mac mini。我不得不用最新的 XCode 切换到 Mac Mini M1。 Plus 让我的 Podfile 看起来像这样。
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
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
【解决方案5】:
将 General -> Deployment Info 下的 Deployment Target 与平台 :ios 匹配,Podfile 中的“11.0”版本为我解决了这个问题。