You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter最新版本更新后iOS构建出现词法/预处理器错误

Flutter更新至最新版本后iOS编译报错:找不到'Flutter/Flutter.h'

更新Flutter到最新版本后,iOS应用无法正常编译启动,更新前可正常运行。调试控制台输出如下:

Xcode build done.                                            6.4s
Failed to build iOS app
Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFWebViewHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFWebsiteDataStoreHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFUserContentControllerHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFWebViewConfigurationHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFUIDelegateHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFScrollViewHostApi.h:4:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/ios/Classes/FWFUIViewHostApi.h:4:8

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

解决步骤

  • 清除Flutter项目缓存并重新拉取依赖
    flutter clean
    flutter pub get
    
  • 清理iOS端Pod缓存并重新安装依赖
    进入项目的iOS目录执行:
    cd ios
    pod deintegrate
    pod install
    
  • 检查webview_flutter依赖版本兼容性
    当前报错的webview_flutter_wkwebview 2.9.5可能与最新Flutter版本不兼容。打开项目的pubspec.yaml文件,将webview_flutter依赖更新到官方推荐的最新兼容版本,之后重新执行flutter pub get和pod install。
  • 重启Xcode和iOS模拟器,确保缓存完全清除
  • 若以上方法无效,手动删除pub缓存中的旧版本webview包:
    rm -rf /Users/modestovascofornas/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5
    
    完成后重新拉取依赖并安装Pod。

内容的提问来源于stack exchange,提问作者mvasco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 14:25:05