Flutter iOS:如何修复“无法构建模块`firebase_core`”?

sta*_*234 8 xcode ios flutter

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

\n
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...\nRunning Xcode build...\nXcode build done.                                           13,1s\nFailed to build iOS app\nError output from Xcode build:\n\xe2\x86\xb3\n    ** BUILD FAILED **\n\n\nXcode's output:\n\xe2\x86\xb3\n    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:\n    In file included from <module-includes>:1:\n    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:\n    In file included from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebaseCorePlugin.h:12:\n    /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]\n\n--------------------------------- HERE --------------------------------\n\n    #import <FirebaseCore/FirebaseCore.h>\n            ^\n    1 error generated.\n    /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'\n\n--------------------------------- HERE --------------------------------\n    #import <firebase_core/FLTFirebasePluginRegistry.h>\n     ~~~~~~~^\n    2 errors generated.\n    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:\n    In file included from <module-includes>:1:\n    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:\n    In file included from /Users/ew/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.8.0/ios/Classes/FLTFirebaseCorePlugin.h:12:\n    /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]\n    #import <FirebaseCore/FirebaseCore.h>\n            ^\n    1 error generated.\n    /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'\n    #import <firebase_core/FLTFirebasePluginRegistry.h>\n     ~~~~~~~^\n    2 errors generated.\n    note: Using new build system\n    note: Building targets in parallel\n    note: Planning build\n    note: Constructing build description\n    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')\n    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')\n    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')\n\nCould not build the application for the simulator.\nError launching application on iPhone 12 Pro Max.\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

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

\n
  firebase_performance: ^0.7.0+7\n  firebase_crashlytics: ^2.1.1\n  firebase_core: any\n  firebase_messaging: ^10.0.6\n  flutter_local_notifications: ^8.1.1+2\n
Run Code Online (Sandbox Code Playgroud)\n

小智 6

删除ios/Pods文件夹。

删除PodfilePodfile.lock

删除pubspec.lock

打开终端并依次运行这些命令

cd ios
pod cache clean --all
flutter clean
flutter pub get
pod install
Run Code Online (Sandbox Code Playgroud)

  • 命令应该是带有两个破折号的“pod cache clean --all” (3认同)
  • 在按照您的指示进行操作时,在最后一部分我收到此错误“[!]在项目目录中找不到 Podfile”。 (2认同)
  • 你需要cd到ios文件夹 (2认同)

Gbe*_*uga -1

这个错误来自 .pub-cache,所以只需 flutter clean,如果错误仍然存​​在,请删除所有 .pub-cache

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

扑干净

和酒吧得到