将 Expo 应用上传到 TestFlight 不加载 .env 文件

huangapple go评论59阅读模式
英文:

Uploading Expo App to TestFlight Doesn't Load .env File

问题

我正在尝试将我的Expo React Native iPhone应用上传到TestFlight,但我的.env文件没有被加载。我使用eas build来获取.ipa文件,并使用Transporter将应用加载到App Store Connect。然而,当我在TestFlight中打开构建时,.env变量没有被加载,因此应用程序无法正常使用。我知道使用Xcode是解决此问题的一种方法,但我使用的是VSCode,而且我的应用程序已经非常庞大,现在从Expo回退不太可行。

英文:

I'm trying to upload my Expo React Native iPhone app to TestFlight but my .env files aren't being loaded. I use eas build to get the .ipa file, and use Transporter to load the app onto App Store Connect. However, when I open the build in TestFlight, the .env variables are not being loaded, so the app is useless. I know that using Xcode is one way to get around this, but I used VSCode, and my app is so large already that going back from Expo now is not really viable.

答案1

得分: 1

当您通过eas build创建新的构建时,您必须将您的环境变量加载到您的Expo项目的secrets中或者加载到eas.json文件中。该文件将如下所示:

{
  "cli": {
    "version": ">= 2.6.0"
  },
  "build": {
    "preview": {
      "distribution": "internal",
      "env": {
        "MY_API_ROUTE": "www.1234.dev.com"
      }
    },
    "production": {
      "env": {
        "MY_API_ROUTE": "www.1234.prod.com"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

更多信息,请查阅:https://docs.expo.dev/build-reference/variables/

英文:

when you create a new build via eas build, you have to load your env variables either in your expo projects secrets or into the eas.json file. That file would then look something like

{
  "cli": {
    "version": ">= 2.6.0"
  },
  "build": {
    "preview": {
      "distribution": "internal",
      "env": {
      "MY_API_ROUTE": "www.1234.dev.com", 
      }
    },
    "production": {
      "env": {
        "MY_API_ROUTE": "www.1234.prod.com", 
      }
    }
  },
  "submit": {
    "production": {}
  }
}

https://docs.expo.dev/build-reference/variables/

huangapple
  • 本文由 发表于 2023年7月17日 22:22:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76705421.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定