致命错误:找不到“Flutter/Flutter.h”文件#import <Flutter/Flutter.h> - iOS

时间:2021-06-20 00:05:40

标签: flutter dart google-cloud-firestore runtime-error

我的应用运行良好,直到我遇到以下问题:“致命错误:找不到‘Flutter/Flutter.h’文件#import ”:

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
lib/main.dart:1
Xcode build done.                                            8.1s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    In file included from /Users/XnameX/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.2/ios/Classes/FLTPathProviderPlugin.m:5:
    /Users/XnameX/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.2/ios/Classes/FLTPathProviderPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    note: Removed stale file '/Users/XnameX/Library/Developer/Xcode/DerivedData/Runner-cfjslqyzzdpnoyeoygvffcmbgtpq/Build/Products/Debug-iphonesimulator/sqflite/sqflite.framework'
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
Exited (sigterm)

我该怎么做才能解决这个问题?非常感谢提前!

1 个答案:

答案 0 :(得分:0)

这对我有用。

  1. 删除您的 .pubcache 文件夹,您可以在安装 flutter 的位置找到它(如果您不确定在哪里,可以运行“which flutter”)它通常是一个隐藏文件,因此您必须启用设置以显示隐藏文件(Shift + Command + 句号在 Mac 上显示隐藏文件)。
  2. 在终端中运行“flutter clean”(确保删除了构建文件夹)
  3. 从 ios 文件夹中删除符号链接、pods 和 podfile.lock
  4. 删除您的 pubspec.lock 文件
  5. 重新构建

如果您仍然遇到问题,您可以进一步 1) 使用“flutter downgrade”降级 Flutter 2)flutter pub缓存修复 3) 删除 ios/Flutter 目录下的 Generated.xcconfig 4)pod install(来自ios目录) 5)重新构建