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

Expo构建iOS应用遇Firebase Swift Pod静态库集成问题

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

针对你遇到的FirebaseCoreInternal依赖GoogleUtilities无法作为静态库集成的问题,以下是Expo项目专属的解决方案(区别于纯React Native项目):

方案一:用Expo官方插件配置(推荐,避免手动修改Podfile被重置)

  1. 安装expo-build-properties插件,用于配置iOS构建参数
npx expo install expo-build-properties
  1. 在app.json或app.config.js中添加插件配置,可选择两种方式:
  • 全局启用模块化头(所有Pod都适配静态库要求)
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useModularHeaders": true
          }
        }
      ]
    ]
  }
}
  • 仅针对出错的依赖设置(更精准,避免影响其他Pod)
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "pods": {
              "GoogleUtilities": { "modularHeaders": true },
              "FirebaseCoreInternal": { "modularHeaders": true }
            }
          }
        }
      ]
    ]
  }
}
  1. 重新执行构建命令(如eas build --platform ios或npx expo run:ios)

方案二:预构建后手动修改Podfile(临时应急)

如果已经执行过npx expo prebuild生成了iOS原生目录,可临时修改Podfile:

  1. 打开ios/Podfile,在文件顶部添加全局配置:
use_modular_headers!

或者针对特定依赖单独设置:

pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
  1. 进入ios目录执行Pod安装:
cd ios && pod install

注意:每次执行npx expo prebuild会重置Podfile,所以长期解决方案优先用方案一。

额外检查

  • 确保你的Expo SDK版本与安装的Firebase包(如@react-native-firebase/app或expo-firebase-core)版本兼容,版本不匹配也可能引发类似构建错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 08:08:25