I've gone through whole installation process, created 2 additional schemes in my app for staging and production - however, when I do xcode archive it seems like the schema preaction is working incorrectly.
For example, preaction script looks like this:
echo ".env.staging" > /tmp/envfile
After successful build, archive and whatnot the application runs fine, but can't do any requests (because api address comes from env variables). So, I checked my /tmp/envfile and it just contains a string ".env.staging" 🤦♂️
Same happens when I run this command in terminal.
Tried that without quotes, tried using cat instead - no success. cat works in terminal, but not in xcode.
Spent fair amount of going through existing issues but nothing I've found would help - is there any solution for that or do I just have to drop this package and figure out something else? The frustration levels are insane right now.
Also, everything works perfectly fine in each environment during development when I use ENVFILE=.env.staging react-native run-ios to run it in sim. It's release builds that are boned.
Help please?
@p-grzelczak
Same here! Did u get any workaround?
@p-grzelczak
Hey just now I rechecked the issue. Problem was with this
@manjuy124 I ended up with this preaction sh script:
cp ${PROJECT_DIR}/../.env.development ${PROJECT_DIR}/../.env
and equivalent for staging and production envs. So my app always uses .env file, which gets content copied from environment specific .env
@p-grzelczak your solution worked perfectly for me!! Any idea why? The documentation states to have something different... What xcode version are you running and is it on legacy build?
@p-grzelczak do you know what ${PROJECT_DIR} is?
the root where the /node_modules are, or is it the root of the /ios folder, or the React-Native
project folder ? Ive tried every combination but nothing works
Most helpful comment
@manjuy124 I ended up with this preaction sh script:
cp ${PROJECT_DIR}/../.env.development ${PROJECT_DIR}/../.envand equivalent for staging and production envs. So my app always uses .env file, which gets content copied from environment specific .env