Hi everyone,
It’s the first time i create an app and i’m having some issues with EAS and the env variable (I think so). I’ve created an app for a burger restaurant and everything work on my local and when i publish the app a release channel with expo publish --release-channel production-v1
.
Now, it’s time to publish my app in the stores, so i would like to create the build for my code in the eas environment and submit into the stores.
I’ve read the documentation but something is missing in my configuration because i tested the app in my android device( throughout a generated apk) and it cannot communicate with the backend server ( I presume that this is the problem because i show a view in this case and i can see it ).
This is my current configuration for eas.json
.
{
"cli": {
"version": ">= 0.38.3"
},
"build": {
"development": {
"releaseChannel": "development",
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"releaseChannel": "production",
"android": {
"buildType": "apk"
},
"env": {
"RELEASE_CHANNEL": "production"
}
}
},
"submit": {
"production": {}
}
}
There is an env variable RELEASE_CHANNEL
which i use in my source code to choose between extra.server
configuration
This is the configuration for app.config.js
export default ({ config }) => {
return {
...config,
hooks: {
postPublish: [
{
file: "sentry-expo/upload-sourcemaps",
config: {
organization: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
setCommits: true,
},
},
],
},
extra: {
server: {
local: process.env.EXPO_LOCAL_SERVER,
development: process.env.EXPO_DEVELOPMENT_SERVER,
production: process.env.EXPO_PRODUCTION_SERVER,
},
secret: {
development: process.env.EXPO_JWT_SECRET_DEVELOPMENT,
production: process.env.EXPO_JWT_SECRET_DEVELOPMENT,
},
mapsToken: process.env.GOOGLE_MAPS_KEY,
placesToken: process.env.PLACES_API,
},
plugins: ["expo-updates", "expo-dev-client"],
};
};
and the file in my source code where i choose the extra.server
variable
const getEnvironment = () => {
let releaseChannel = process.env.RELEASE_CHANNEL ?? Constants.manifest.releaseChannel;
if (releaseChannel === undefined)
// since releaseChannels are undefined in dev, return your default.
return getObjectEnvironment(
Constants.manifest.extra.server.local,
Constants.manifest.extra.secret.development,
Constants.manifest.extra.mapsToken,
Constants.manifest.extra.placesToken
);
if (releaseChannel.indexOf("development") !== -1)
// this would pick up development-v1, development-v2 ...
return getObjectEnvironment(
Constants.manifest.extra.server.development,
Constants.manifest.extra.secret.development,
Constants.manifest.extra.mapsToken,
Constants.manifest.extra.placesToken
);
if (releaseChannel.indexOf("production") !== -1)
// this would pick up production-v1, production-v2 ...
return getObjectEnvironment(
Constants.manifest.extra.server.production,
Constants.manifest.extra.secret.production,
Constants.manifest.extra.mapsToken,
Constants.manifest.extra.placesToken
);
};
These are my env
variable on my local environment. Of course, i added all of these varibles (except EXP_LOCAL_SERVER) into my secret section for my app in the expo configuration.
# SERVERS
EXPO_LOCAL_SERVER=XXX
EXPO_DEVELOPMENT_SERVER=XXX
EXPO_PRODUCTION_SERVER=XXX
# AUTHENTICATION TOKEN
EXPO_JWT_SECRET_DEVELOPMENT=XXX
# GOOGLE MAPS KEY
GOOGLE_MAPS_KEY=XXX
PLACES_API=XXX
# SENTRY_ORG
SENTRY_PROJECT=XXX
SENTRY_ORG=XXX
SENTRY_AUTH_TOKEN=XXXX
This is my mental flow ( let me know if i am wrong) how work the build process with env environment. The build process set the variables into process.env
so in the app.config.js
files are available and are used to set the Constants.manifest.extra
properties. Then in my source code, i use process.env.RELEASE_CHANNEL
variable which is defined in eas.json
file to choose the correct environment. In case this variable is not defined , i use Constants.manifest.releaseChannel
to publish the app into expo or for my local development.
I am using a managed flow, so i can’t use the development environment ( expo start --dev-client
) to test it because when i run the previous command, the output says that i need a bare flow
so, what is wrong?
btw, my eas-cli version is eas-cli/0.38.3 linux-x64 node-v14.18.1
Thanks in advance