【问题标题】:Flutter iOS: How to fix "Could not build module `firebase_core`"?Flutter iOS:如何修复“无法构建模块`firebase_core`”?
【发布时间】:2021-12-17 04:18:52
【问题描述】:

我有一个颤振项目。首先,它必须在 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

【问题讨论】:

    标签: ios xcode flutter


    【解决方案1】:

    这个错误来自 .pub-cache,所以只要清理干净,如果错误仍然存​​在,则删除所有 .pub-cache

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

    颤抖干净

    然后发布获取

    【讨论】:

      【解决方案2】:

      在 pubspec.yaml 添加 firebase_core:any 。然后运行flutter cleanflutter pub get。然后从终端 cd ios 中的项目根目录导航到 iOS 文件夹。然后运行pod install。现在运行flutter run,它应该会按预期工作。

      【讨论】:

      • 我做了这些,但我仍然有同样的问题。
      • 在您的终端中运行rm -r ~/.pub-cache 请注意,这将删除您系统中的 .pub-cache 文件夹。删除 Podfile.lock,然后删除 flutter cleanflutter pub getpod install
      【解决方案3】:

      对我有用的是使用 Firestore iOS SDK 的预编译版本,因为在编译过程中出现了问题。请参阅https://firebase.flutter.dev/docs/overview/#initializing-flutterfire 上的“改进 iOS 构建时间”部分

      1. 从您的 podfile(例如 pod 'Firebase/Analytics')。
      2. 将预编译的 pod 添加到您的 podfile(参见上面的链接)。

      我已将pod 'FirebaseFirestore', :git =&gt; 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag =&gt; '8.7.0' 添加到 podfile 中的 runner 目标(这是旧版本,因为新版本也出现了一些错误)。

      结果在您的 podfile 中如下所示:

      target 'Runner' do
        use_frameworks!
        use_modular_headers!
        pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.7.0'
        flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
      end``` 
      

      【讨论】:

        猜你喜欢
        • 2021-08-08
        • 2021-08-06
        • 2020-06-06
        • 2022-07-28
        • 2022-07-25
        • 2021-06-05
        • 2016-12-07
        • 2021-11-27
        • 2020-09-17
        相关资源
        最近更新 更多