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

升级Xcode 15后Flutter项目报错:'Flutter/Flutter.h'文件未找到

解决Xcode 15升级后Flutter构建报错:'Flutter/Flutter.h'文件找不到

报错信息

无法为设备构建预编译应用。
Swift Compiler Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/pedrocovarrubias/.pub-cache/hosted/pub.dev/vibration-1.8.2/ios/Classes/VibrationPlugin.h:0:8
Swift Compiler Error (Xcode): Could not build Objective-C module 'vibration'

已尝试操作

  • 备份Runner文件夹
  • 删除ios文件夹并重新执行flutter create .
  • 恢复备份的Runner文件夹
  • 执行pod deintegrate、pod install
  • 执行flutter clean、flutter pub get、flutter run
  • 重新导入GoogleService-Info.plist

pod install后提示

[!] CocoaPods未设置项目的基础配置,因为项目已有自定义配置。请将Runner目标的基础配置设置为Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig,或在构建配置(Flutter/Release.xcconfig)中包含该文件。
[!] Runner [Debug]目标覆盖了Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig中定义的ENABLE_BITCODE构建设置,建议使用$(inherited)标志或移除目标中的该设置。
[!] Runner [Release]目标覆盖了Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig中定义的ENABLE_BITCODE构建设置,建议使用$(inherited)标志或移除目标中的该设置。
[!] Runner [Profile]目标覆盖了Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig中定义的ENABLE_BITCODE构建设置,建议使用$(inherited)标志或移除目标中的该设置。

解决方案

1. 修复CocoaPods基础配置引用

打开ios目录下的Runner.xcworkspace,选中Runner目标,切换到Build Settings标签:

  • 搜索Base Configuration,分别为Debug、Release、Profile三个配置项设置对应文件:
    • Debug:Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig
    • Release:Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig
    • Profile:Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig
  • 若需保留自定义xcconfig,可在你的自定义配置文件(如Flutter/Release.xcconfig)末尾添加:#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"(对应不同配置替换后缀)

2. 修复ENABLE_BITCODE继承问题

在Runner目标的Build Settings中搜索ENABLE_BITCODE:

  • 将Debug、Release、Profile三个配置的ENABLE_BITCODE值改为$(inherited),或直接删除该自定义设置,让项目继承Pods的配置

3. 重新构建依赖

回到项目根目录,依次执行以下命令:

flutter clean
rm -rf ios/Pods ios/Podfile.lock ios/Runner.xcworkspace
flutter pub get
cd ios && pod install

4. 更新vibration插件(若上述步骤无效)

旧版本vibration插件可能不兼容Xcode 15,修改pubspec.yaml中的依赖为最新版本(可查询pub.dev获取最新号):

vibration: ^1.8.4

执行flutter pub get后重新尝试构建。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 06:00:22