首页 > 解决方案 > Expo app.config.js googleServicesFile 用于不同的构建变体

问题描述

我希望能够区分我的 Expo 应用程序上的构建变体。

目前我的 app.config.js 中有我的 expo 配置,就像这样


import Constants from 'expo-constants';

let AndroidGoogleServicesFile = './google-services-dev.json';

if (Constants.manifest.releaseChannel === 'staging') {
  AndroidGoogleServicesFile = './google-services-staging.json';
}
if (Constants.manifest.releaseChannel === 'release') {
  AndroidGoogleServicesFile = './google-services.json';
}
...
{
...
android: {
  adaptiveIcon: {
    foregroundImage: './assets/images/adaptive-icon.png',
    backgroundColor: '#FFFFFF',
  },
  package: 'com.companyname.App',
  googleServicesFile: AndroidGoogleServicesFile,
},
...

如您所见,我希望能够配置我googleServicesFile的基于releaseChannel或构建变体,但目前这似乎不可能?我也在使用 EAS 来构建,我不确定我是否可以在我的eas.json任何一个中配置它......

标签: react-nativeexpo

解决方案


推荐阅读