flutter - 致命错误:找不到“Flutter/Flutter.h”文件
问题描述
当我在 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>
我尝试过这种方式来修复它:
~/apps/flutter/bin/flutter clean
没用,然后我尝试了这种方式:
$ 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)
仍然无法正常工作,为什么会发生这种情况,我应该怎么做?这是我的频道:
$ ~/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)
解决方案
由于您有旧版本的颤振(9 月发布),我建议您将颤振升级到最新的稳定版本,即 1.22.5。只需在终端输入
flutter upgrade
如果这没有帮助,请删除 ios 文件夹,然后输入项目的根目录
flutter create .
重新创建 ios 文件夹并再次尝试构建。
推荐阅读
- git - 如何知道我的本地分支合并到哪个远程分支
- c++ - 使用 GoogleMock 模拟由被测代码创建的实例
- php - PHP Soap“捕获异常:服务器无法处理请求。---> 对象引用未设置为对象的实例。”
- apache-flink - Apache Flink:作业完成后如何做一些动作?
- php - 使用 php 和 mysql 进行搜索查询的问题
- swift - 如何快速为每个单元格添加不同的附件(或子视图)?
- python - Python 3 Multiprocessing - 我应该使用多少个进程?
- c++ - C++:为什么会出现错误:“数组初始值设定项必须是初始值设定项列表或字符串文字”?
- amazon-web-services - 识别目标组中的 AWS 不健康主机
- html - 无法在我的 html 页面中集成 mp4 视频