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

Expo托管式RN项目EAS构建iOS时遇GoogleService-Info.plist缺失报错

解决EAS构建iOS时GoogleService-Info.plist缺失的问题

步骤1:重新生成GoogleService-Info.plist的Base64编码

EAS Secrets仅支持存储字符串,不能直接上传文件,需将plist文件转为Base64编码:

  • Mac/Linux终端执行:base64 -i GoogleService-Info.plist,复制输出的编码字符串
  • Windows PowerShell执行:[Convert]::ToBase64String([IO.File]::ReadAllBytes("GoogleService-Info.plist")),复制结果

前往EAS Dashboard项目Secrets页面,更新GOOGLE_SERVICES_PLIST的值为上述Base64字符串(替换之前直接上传的文件)。

步骤2:修改app.config.js,动态生成plist文件

替换原有固定路径配置,添加预构建逻辑从环境变量解码生成文件:

import { ExpoConfig, ConfigContext } from '@expo/config';
import * as fs from 'fs';
import * as path from 'path';

export default ({ config }: ConfigContext): ExpoConfig => {
  // EAS构建环境下,从环境变量解码生成plist文件
  if (process.env.GOOGLE_SERVICES_PLIST) {
    const plistPath = path.join(__dirname, 'GoogleService-Info.plist');
    const plistBuffer = Buffer.from(process.env.GOOGLE_SERVICES_PLIST, 'base64');
    fs.writeFileSync(plistPath, plistBuffer);
  }

  return {
    ...config,
    ios: {
      ...config.ios,
      supportsTablet: true,
      bundleIdentifier: "com.saffronai.saffronai",
      googleServicesFile: "./GoogleService-Info.plist",
    },
  };
};

步骤3:确认eas.json配置正确性

检查现有eas.json中各iOS构建profile(development-ios、production)的env字段,确保GOOGLE_SERVICES_PLIST与EAS Secret名称完全一致(大小写敏感),你的当前配置符合要求,无需修改。

步骤4:保持.gitignore配置

确保GoogleService-Info.plist已加入.gitignore,避免提交到代码仓库,现有操作无需调整。

步骤5:重新触发EAS构建

执行对应平台的构建命令,例如:

eas build --profile development-ios --platform ios

额外注意事项

  • 无需在本地手动存放GoogleService-Info.plist,构建过程完全依赖环境变量生成文件
  • 确认rn-firebase版本与当前Expo SDK版本兼容,避免版本冲突导致文件读取异常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 00:48:24