首页 > 解决方案 > Flutter iOS:如何修复“无法构建模块`firebase_core`”?

问题描述

我有一个颤振项目。首先,它必须在 android 及其工作上工作!一切都很酷。是时候让它在 iOS 上运行了,但是当我尝试在 iOS 模拟器上启动项目时出现以下错误:

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...
Xcode build done.                                           13,1s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    While building module 'firebase_core' imported from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-10.0.6/ios/Classes/FLTFirebaseMessagingPlugin.m:6:
    In file included from <module-includes>:1:
    In file included from /Users/ew/Dev/projects/SWIE%20-%20ink%20-%20mobil/ios/Pods/Target Support Files/firebase_core/firebase_core-umbrella.h:13:
    In file included from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebaseCorePlugin.h:12:
    /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebasePlugin.h:9:9: error: include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin': '/Users/ew/Dev/projects/SWIE%20-%20ink%20-%20mobil/ios/Pods/Headers/Public/FirebaseCore/FirebaseCore.h' [-Werror,-Wnon-modular-include-in-framework-module]

--------------------------------- HERE --------------------------------

    #import <FirebaseCore/FirebaseCore.h>
            ^
    1 error generated.
    /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-10.0.6/ios/Classes/FLTFirebaseMessagingPlugin.m:6:9: fatal error: could not build module 'firebase_core'

--------------------------------- HERE --------------------------------
    #import <firebase_core/FLTFirebasePluginRegistry.h>
     ~~~~~~~^
    2 errors generated.
    While building module 'firebase_core' imported from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-10.0.6/ios/Classes/FLTFirebaseMessagingPlugin.m:6:
    In file included from <module-includes>:1:
    In file included from /Users/ew/Dev/projects/SWIE%20-%20ink%20-%20mobil/ios/Pods/Target Support Files/firebase_core/firebase_core-umbrella.h:13:
    In file included from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebaseCorePlugin.h:12:
    /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebasePlugin.h:9:9: error: include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin': '/Users/ew/Dev/projects/SWIE%20-%20ink%20-%20mobil/ios/Pods/Headers/Public/FirebaseCore/FirebaseCore.h' [-Werror,-Wnon-modular-include-in-framework-module]
    #import <FirebaseCore/FirebaseCore.h>
            ^
    1 error generated.
    /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-10.0.6/ios/Classes/FLTFirebaseMessagingPlugin.m:6:9: fatal error: could not build module 'firebase_core'
    #import <firebase_core/FLTFirebasePluginRegistry.h>
     ~~~~~~~^
    2 errors generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'Toast' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'FMDB' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'Reachability' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.

可悲的是,我没有找到任何可行的解决方案......

这是我的 pubspec.yaml(firebase 依赖项):

  firebase_performance: ^0.7.0+7
  firebase_crashlytics: ^2.1.1
  firebase_core: any
  firebase_messaging: ^10.0.6
  flutter_local_notifications: ^8.1.1+2

标签: iosxcodeflutter

解决方案


这个错误来自 .pub-cache 所以只是颤抖干净,如果错误仍然存​​在,请删除所有 .pub-cache 然后

从 pubspec.yaml 中的依赖项中删除包,运行 flutter packages get。然后再次将包添加到依赖项并运行flutter packages get。这个过程过去为我解决了这个问题。

扑干净

和酒吧得到


推荐阅读