-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified variables are not updated after rebuilding #591
Comments
@mickael-h Faced the same issue, fixed it by clearing the xcodederiveddata in your system. |
Faced the same issue, every time need to manually remove node_modules/react-native-config/ios/ReactNativeConfig/GeneratedDotEnv.m. Any updates on the handling? |
Just removing the GeneratedDotEnv.m file didn't help me, that caused a compile error, because the import then fails in ReactNativeConfig.m, line 2. Running "Clean Build Folder" in Xcode works for me. This ensures the '[CP-User] Config codegen' build phase script in the Pods project is run again and the content of GeneratedDotEnv.m is regenerated. |
@pvroosendaal , thanks for that update. |
how about another solution ? |
running Running "Clean Build Folder" in Xcode does work. i think it's time to switch to another library as we have wasted too much time on this one. Going to try react-native-dotenv, i don't think it could be worse than this one 🤣 |
Fixed in |
Just tested here and it still does not update environment variables after rebuilding the code |
Same here. We need to reopen the issue. |
@luancurti We are verry sorry, but it does not work with 1.4.12. :) Pls reopen the issue. |
same, not working with 1.4.6 |
Same in 1.5.0 |
Same in 1.4.5 |
I just delete Pods and rerun yarn ios and it seems to always work for me.
|
Perfect dude, thank you! This is the quickest! Not even a PS: You don't need |
Same issue, pod install is not fixing it consistently though. |
Same with the last version, ios is cached all the time |
what canw e do to fix this? |
It's not working |
Edit: I was wrong, it is working. Make sure the path to your |
hey @gCardinal what do you mean by |
Everyone: This module is pretty simple. It generates a file and puts it in Pods. It does that when you yarn install - and only if it is not already there. So you have 2 choices. 1. Delete Pods - then rerun Got it? |
@billnbell the problem is only on iOS that if I make a change on my .env file it doesn't read that change and keep the first one. I need to delete node_modules and until then reads the new one. Sorry I'm a beginner on this. |
I mean instead of pointing to files like so I also did not need to delete my pods when changing a value - I do however need to clean the project in XCode. I am also not using the environment variable way to point to different files. I had to do it this way, so in the end I have something like this in my Podfile:
This was what finally worked for me, but as I said, when I change values, I need to clean the project. No other way around it that I could find. |
Thank you so much @gCardinal 🥇 |
This works for me. To be more specific, I added the following script to my package.json, which I run every time I change the contents of my .env file:
I am using different schemes in my project which means I have a .env.prod, .env.develop, and .env.qa file, the contents of which are copied into the main .env file when running the associated scheme. I always delete derived data before switching the scheme I'm running locally. |
@jackkrone that worked for me. Thanks |
i fixed this issue using this |
Same issue with iOS still persists. for me deleting the pods and reinstalling them worked but it takes a lot of time for me for just to rewrite the env variables. |
Yeah to fix this correctly we need to add to the pipeline an env variable check or something "RESET_CONFIG=1" and then when building delete the file and re-generates. I am sure this is not a high priority - but the author of this package should see if there is a way to make this easier to regenerate the generated files. |
This is still an issue. Seriously we don't have a good solution yet? |
I think they take PRs :) |
I tried pretty much everything suggested here and it still doesn’t work... |
Got it fixed by generating Inside
|
i gave up and started using expo. it just... works! never turning back. |
I added |
I'm having this issue, any solution? only running "Clean Build Folder" in Xcode does work |
Just use expo @Biplovkumar @joaquinvaz |
I have renamed .env.development |
I found the solution. I format my disk and reinstall the OS and the variable updates. Works every time. PS: Found a trick on another github thread:
|
It works 100% of the times.. Thanks for the solution 👏 🎆 |
Anything speaking against doing it like this:
|
This is not a solution |
I think this is pretty much it. A simple update to the documentation would suffice IMHO. I would add |
Why is this closed when this issue apparently still exists? |
It not work for me |
This worked for me on ios! Apr 6 2024 |
The issue still exists on iOS and deleting .env files every build isn't a good idea at all |
The problem is not the env file nor the xcode cache. The problem is that a file is written into the ios and android directories of this library. A workaround that I am using is to create a "prestart": "rm -f node_modules/react-native-config/ios/ReactNativeConfig/GeneratedDotEnv.m node_modules/react-native-config/android/build/generated/source/buildConfig/debug/com/lugg/RNCConfig/BuildConfig.java node_modules/react-native-config/android/build/generated/source/buildConfig/release/com/lugg/RNCConfig/BuildConfig.java" This requires us to restart the metro bundler when we've updated the env - Which to me makes sense. |
From reading the comments, this works for me when I change a custom ENV variable URL from server to localhost for running a local backend and then starting my React Native app (following is from my "scripts" in package.json:
npm run ios Starts a new terminal window (like it used to before newer React Native versions). And it now reads the correct env variables that I updated in the .env file in the project root. |
Script |
You saved me from stupid dog shit I faced 2 days You saved me from stupid dog shit 2 day, thank god |
I keep changing variable values in the .env file, but recompiling the app doesn't change anything (at least on iOS)
I tried cleaning every cache I could think of, but the config values are still the same as the first build.
Could you give instructions in order to clean the .env cache?
The text was updated successfully, but these errors were encountered: