为 react-native-firebase googleServicesFile 展示多个环境

问题描述 投票:0回答:1

我有一个问题,我不知道如何处理。在我的应用程序(Expo SDK 48)中,我想为每个 expo 环境有一个单独的 googleServicesFile 源,即对于开发环境,我想要一个单独的 googleServicesFile 用于开发,测试、uat 和 prod 也是如此。

我试图解决它,在 eas.json 文件中我有几个用于开发、uat、prod 环境的配置文件,然后在 app.config.js 文件中,我检查当前附加了哪个配置文件并在此基础上为 googleServicesFile 分配适当的路径,但不幸的是,无论我将运行什么配置文件,数据始终保存在开发配置文件中。你们中有人为 Expo React Native 创建了多个 googleService 配置并想分享我如何去做吗?

eas.json

"build": {
  "development": {
     "distribution": "internal",
     "android": {
       "gradleCommand": ":app:assembleDebug"
     },
     "env": {
       "APP_VARIANT": "stage"
     }
   },
  "uat": {
    ...,
    "env": {
       "APP_VARIANT": "uat"
     }
  }
app.config.js

"expo": {
  ...,
  "ios": {
    "googleServicesFile": process.env.APP_VARIANT === 'development' ? "./firebase/development/GoogleService-Info.plist" : "./firebase/uat/GoogleService-Info.plist",
  },
}

此外,在主项目位置我有一个 firebase 文件夹,我在其中存储 firebase 文件 - GoogleService-Info-.plist 适用于 IOS 和 google-service.json 适用于 Android。

/firebase
  - development
    - GoogleService-Info.plist
    - google-service.json
  - uat
    - GoogleService-Info.plist
    - google-service.json
firebase react-native expo react-native-firebase eas
1个回答
1
投票

为了按不同的开发环境划分

Google Services files
,可以在
ios
文件中的
expo
对象下添加一个
app.json
对象,并为每个开发环境设置不同的
Google ServicesFile

  • 例子
{
  "expo": {
    // ...
  },
  "ios": {
    "googleServicesFile": {
      "dev": "./GoogleService-Info-dev.plist",
      "stage": "./GoogleService-Info-stage.plist",
      "production": "./GoogleService-Info-prod.plist"
    }
  }
}

何时

dev
建造

expo build:ios --no-publish --config app.dev.json
© www.soinside.com 2019 - 2024. All rights reserved.