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:
- Adding new configurations Dev and Qa with XCode
- Adding new schemes for Dev and Qa with XCode
- 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:
- If run the project
myapp.Dev
with XCode
get variable from .env (wrong) bundle identifier is Dev (correct)
- 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 ?
As my concern, I'm using this library :
react-native-config