致命错误:找不到“Flutter/Flutter.h”文件

Dol*_*hin 8 flutter

当我在 mac book pro 中编译我的项目时,显示此错误:

Xcode's output:
?
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/JavaScriptChannelHandler.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/JavaScriptChannelHandler.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+4/ios/Classes/FLTSharedPreferencesPlugin.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+4/ios/Classes/FLTSharedPreferencesPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FlutterWebView.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FlutterWebView.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTWebViewFlutterPlugin.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTWebViewFlutterPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTWKNavigationDelegate.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTWKNavigationDelegate.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTCookieManager.m:5:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.24/ios/Classes/FLTCookieManager.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.1.4+2/ios/Classes/WakelockPlugin.m:1:
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.1.4+2/ios/Classes/WakelockPlugin.h:1:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/dolphin/.pub-cache/hosted/pub.flutter-io.cn/video_player-0.10.12+5/ios/Classes/messages.m:4:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
Run Code Online (Sandbox Code Playgroud)

我尝试通过这种方式修复它:

~/apps/flutter/bin/flutter clean
Run Code Online (Sandbox Code Playgroud)

没有用,然后我尝试了这种方式:

$ pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Users/dolphin in PATH, mode 040777
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 15 dependencies from the Podfile and 18 total pods installed.

[!] A license was specified in podspec `sentry_flutter` but the file does not exist - /Users/dolphin/Documents/GitHub/cruise-open/ios/.symlinks/plugins/LICENSE

[!] Unable to read the license file `../../LICENSE` for the spec `sentry_flutter (0.0.1)`

[!] Unable to read the license file `../../LICENSE` for the spec `sentry_flutter (0.0.1)`

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
(base)
Run Code Online (Sandbox Code Playgroud)

仍然不起作用,为什么会发生这种情况,我该怎么办?这是我的频道:

$ ~/apps/flutter/bin/flutter doctor -v
[?] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.7 19H114, locale en-CN)
    • Flutter version 1.20.4 at /Users/dolphin/apps/flutter
    • Framework revision fba99f6cf9 (4 months ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[?] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/dolphin/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[?] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.0

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[!] IntelliJ IDEA Community Edition (version 2020.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
    • IntelliJ at /Users/dolphin/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[?] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[?] Connected device (1 available)
    • iPhone 11 Pro (mobile) • 4FEAF225-103D-4237-96D7-026059D2BDB4 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-7
      (simulator)

! Doctor found issues in 3 categories.
(base)
Run Code Online (Sandbox Code Playgroud)

pas*_*sty 2

由于您使用的是较旧版本的 flutter(9 月发布),我建议您将 flutter 升级到最新的稳定版本 1.22.5。只需在终端中输入

flutter upgrade
Run Code Online (Sandbox Code Playgroud)

如果这没有帮助,请删除 ios 文件夹,然后输入项目的根目录

flutter create .
Run Code Online (Sandbox Code Playgroud)

重新创建 ios 文件夹并再次尝试构建。