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

Flutter iOS运行报错Could not build module `firebase_core`如何修复?

Flutter iOS端Firebase构建报错解决方案

报错核心原因

  1. 构建时出现include of non-modular header inside framework module错误,是Firebase相关插件的iOS端依赖默认不允许非模块化头文件引入导致
  2. 部分第三方iOS依赖最低支持版本为9.0,项目默认配置的8.0部署目标触发版本不兼容警告,也可能引发构建失败

操作步骤

  • 第一步:修改ios/Podfile配置
    1. 取消文件开头的platform注释,将最低iOS版本调整为10.0:
    platform :ios, '10.0'
    
    1. 找到文件末尾的post_install块,替换为以下内容,统一所有Pods的部署目标,同时允许非模块化头文件引入:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
          config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
        end
      end
    end
    
  • 第二步:清理缓存重新安装依赖
    依次在项目根目录执行以下命令:
    flutter clean
    flutter pub get
    cd ios
    rm -rf Pods Podfile.lock
    pod repo update
    pod install
    
  • 第三步:Xcode配置修正(如上述操作后仍报错可执行)
    用Xcode打开ios/Runner.xcworkspace,选中Runner主项目,进入Build Settings页,搜索Allow Non-modular Includes in Framework Modules,将对应值设置为YES。
  • 第四步:依赖版本对齐(可选,解决版本冲突)
    你当前pubspec.yaml中firebase_core设置为any可能拉取到和其他Firebase插件不兼容的版本,可将其锁定为匹配版本:
    firebase_core: 1.8.0
    
    修改后重新执行flutter pub get和pod install即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 16:15:03