React Native Environmental Variables in VS App Center

180 Views Asked by At

I am struggling with getting .env variables to show up in my React Native app, when compiling with VS App Center. I am using react-native-config, and have a local .env file that work when developing locally, but when I build with VS App Center, the predefined environment variables in the console, are available via the app.

I have added the following variables in the console: screenshot of app center varibles

Then, I have created a appcenter-post-clone.sh in the root directory of the project:

#!/usr/bin/env bash

echo "Creating .env file"
cat > ./.env <<EOL
API_URL=${API_URL}
GOOGLE_API_KEY=${GOOGLE_API_KEY}
EOL

However, no .env is created - there is nothing in the build log with Creating .env file, so I am confused on what the best path is here. Does anyone have any guidance here on how to read .env values with App Center builds?

0

There are 0 best solutions below