reemee
reemee

Reputation: 1

How to set environment variables when deploying without using EAS on EXPO

I'm implementing the project after the expo prebuild.

I'm take three environments: development, staging, and production. because 'dev' is the environment that developers will use to do development, and 'staging' is for internal staff to do QA. Finally, 'prod 'is the environment that will be shown to real users.

Each environment has different API URLs or different environment settings, so you'll need to adapt the .env file differently.

This wasn't a problem when I was developing, because I had files like .env.development, .env.staging, etc. in the root path and could select the desired environment at runtime with a command of NODE_ENV=select environment.

The problem is when you actually deploy the app. This is especially problematic for me because I won't be using EAS because it's a paid service.

Again, I want to deploy the app manually and not use EAS. Like with the react-native-cli.

So I tried to install and use 'react-native-config' to build for each environment.

I had the following issues on IOS

  1. create each .env file in the .env folder

  2. install react-native-config

  3. xcode > project name click > new file > Configuration Settings FIle and Enter in that file #include?“tmp.xcconfig”

  4. go to project > Info > Configurations and apply the config to Debug, Release

  5. create a scheme. target is an existing scheme.

  6. in the created scheme, go to Edit Scheme > Build > Pre-actions

enter the following in the run script

 cp “${PROJECT_DIR}/../.env/.env.development” “${PROJECT_DIR}/../.env”

“${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb” ‘${SRCROOT}/..’ ”${SRCROOT}/tmp.xcconfig”

When I do this, I get xcode error exited with status code 127 error.

terminal error is The following build commands failed:Run custom shell script 'Run Script'eyJ0eXBlIjp7IndvcmtzcGFjZSI6e319fQ==

Did I do something wrong? It a run script error, but the react-native-config documentation also says to write the run script like this.

(react-natvie-config doc)

If you know how to fix this, or how to archive environment variables differently per schema when deploying to the app store after another expo prebuild, please let me know.

I'm stumped for the second day, thank you.

Upvotes: 0

Views: 398

Answers (0)

Related Questions