0

I use react-native-config with XCode setting.

I want to have three version are

myapp

Prod

myapp.Dev

Dev

myapp.Qa

Qa

Here is my step:

  1. Adding new configurations Dev and Qa with XCode
  2. Adding new schemes for Dev and Qa with XCode
  3. set User-Defined for Dev and Qa with different bundle identifier

I run the project with XCode, It works, I can see three apps on simulator (Dev Qa Prod)

then I want to get variant from different file, so I set three env file

.env

API_URL=https://myapi.com

.env.dev

API_URL=https://myapi.dev.com

.env.qa

API_URL=https://myapi.qa.com

I also set the Run Script with XCode, for instance myapp.Dev is cp "${PROJECT_DIR}/../.env.dev" "${PROJECT_DIR}/../.env"

I have two problems:

  1. If run the project myapp.Dev with XCode

get variable from .env (wrong) bundle identifier is Dev (correct)

  1. If I run the command ENVFILE=.env.dev npx react-native run-ios to build the project,

get variable from .env file (wrong) and variable becomes to https://myapi.dev.com, bundle identifier is Prod (wrong)

I have no idea what step is wrong, how do I just run mypp.Dev and read from .env.Dev file ?

Morton
  • 5,380
  • 18
  • 63
  • 118

1 Answers1

-2

As my concern, I'm using this library :

react-native-config

JSharles
  • 565
  • 1
  • 5
  • 16