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

使用EAS Build构建Expo iOS应用时遇Firebase SDK静态库错误

解决Expo EAS Build iOS构建时Firebase SDK静态库集成错误

针对你遇到的FirebaseCoreInternal依赖GoogleUtilities无法作为静态库集成的问题,以下是适配Expo项目的解决方案:

方案1:通过自定义Expo Config Plugin配置Pod模块化头

Expo允许通过Config Plugin在构建时自动修改原生配置,无需手动编辑Podfile:

  1. 安装依赖(若未安装):
npm install @expo/config-plugins --save-dev
  1. 在项目根目录创建withFirebaseModularHeaders.js文件,内容如下:
const { withPodfileProperties } = require('@expo/config-plugins');

module.exports = function withFirebaseModularHeaders(config) {
  return withPodfileProperties(config, (config) => {
    // 全局开启模块化头,解决Swift Pod静态库问题
    config.modResults.use_modular_headers = true;
    return config;
  });
};
  1. 在app.json/app.config.js的expo.plugins中引入该插件:
{
  "expo": {
    // ...其他配置
    "plugins": ["./withFirebaseModularHeaders.js"]
  }
}

完成后重新触发EAS Build,插件会自动在构建流程中修改Podfile配置。

方案2:调整Firebase版本适配Expo 48

Expo 48基于React Native 0.71.3,部分高版本Firebase可能存在兼容性问题,尝试降级到适配版本:

npm install firebase@9.19.0 --save

随后清理缓存并重装依赖:

npm cache clean --force
rm -rf node_modules && npm install
npx expo prebuild --clean

方案3:生成原生代码后手动修改Podfile(备选)

若上述方案无效,可生成原生代码后手动调整Podfile:

  1. 生成iOS原生代码:
npx expo prebuild --platform ios
  1. 打开ios/Podfile,添加全局模块化头配置:
use_modular_headers!

或者针对特定依赖单独设置(若全局开启有冲突):

pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
  1. 将修改后的原生代码提交到版本控制,再运行EAS Build。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 11:00:23