react-native-config: Not working with RN 0.60.4
The library is not working with RN 0.60.4
, automatic linking is not working. If I try to link manually, it throws errors. On pod install
it produces error 'GeneratedDotEnv.m' file not found
.
Any help? š
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 42
- Comments: 50 (2 by maintainers)
@Elvinra that worked for me!!
Another fix, if you install with npmjs, then
yarn add react-native-config
Open podfile and addcd iOS && pod install
Here is the guide for some poor soul javascript dev like me out there:
yarn add luggit/react-native-config#master
(donāt use the version on npm or you will spend way too much time to figure out how this work) Note: if you want to anchor your version then use this commit instead of master https://github.com/luggit/react-native-config/commit/1eb6ac01991210ddad2989857359a0f6ee35d734README
, you donāt need to add any code inside yourPodfile
Afterpod install
there will be some warning like this[!] react-native-config has added 1 script phase.
(which mean you are doing this right) 2a. If your want to supportInfo.plist
, replace__RN_CONFIG_xxx
to$(xxx)
inside yourInfo.plist
fileOn the side note, the
README
should be restructure for it is very confusingWhat worked for me now on 0.60.4, inspired by @Mlobaievskyi and @s123121 -
react-native-config
ver to master"react-native-config": "github:luggit/react-native-config#master"
or lock commit to 1eb6ac0 as @s123121 said. Thennpm install
itreact-native.config.js
Ā at root folder (Not sure if necessary)Podfile
and the lineĀ
pod 'react-native-config', :path => '../node_modules/react-native-config'
then runĀpod install
again (To be safe you can deletePodfile.lock
first)Then I was getting
'GeneratedDotEnv.m' file not found.
error After battling it a while I realized from this PR (https://github.com/luggit/react-native-config/commit/1eb6ac01991210ddad2989857359a0f6ee35d734) that I should remove all these preprocess settings. After that'GeneratedDotEnv.m' file not found.
error is gone and it works for me.You are using react-native-config from npmjs, try to use this librairy directly from github yarn add https://github.com/luggit/react-native-config
Can we have a new release from
master
? I donāt feel comfortable hardcoding a repository link in mypackage.json
.@ninjz you are correct remember that choose your target for Provide build settings form
What Iām doing for RN 0.60.4 (Upgraded from 0.59.9) is basically
react-native-config
ver to master"react-native-config": "github:luggit/react-native-config#master"
or lock commit to 1eb6ac0 as @s123121 said. Thennpm install
itpod 'react-native-config', :path => '../node_modules/react-native-config'
in PodfileLink Binary with libraries
in your XCode Workspace.rb
instead of.ruby
for me (Thanks @mchudy)pod install
atios
folderBut Iām getting this now, anyone knows why?
@fariasmark Try replacing
BuildDotenvConfig.ruby
withBuildDotenvConfig.rb
. It helped in my case.I had to replace that last line with:
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb \"${SRC_ROOT}/../\" \"${SYMROOT}\""
I need help! Iāve try @dineshmm23ās solution but Iām still getting this error:
ruby: No such file or directory ā ./node_modules/react-native-config//ios/ReactNativeConfig/BuildDotenvConfig.ruby (LoadError)
Command PhaseScriptExecution failed with a nonzero exit code
@Mlobaievskyi Thatās so wierd lol Iām still trying to figure out this error
Iām using react-native-config 1.4.1 and was running into the empty object problem on ios so I added a new run script within Build Phases and got the config correctly populated as expected:
Update:
Create a new run script and paste the above in there. Update your .env files within the script above accordingly. Iām using
.env.production
and.env.development
for release and debug builds respectively.In order to change between debug and release builds you can go to āEdit schemesā for your target:
And select between the 2 builds:
The next build and run of your app should contain the contents between your various env files.
THIS WORKS!!!
Found solution
yarn add react-native-config
react-native.config.js
react-native run-ios
(archive also work)I just upgraded my React Native version to 0.61.4 and react-native-config ^0.12.0. @kdenz solution worked for me.
Iām also having some trouble with getting RN0.60.4 to work with this library. I get an error in the preprocessing Info.plist
It seems like thereās so many different fixes each for different versions and if people have multiple envs.
Can we get some way of version controlling each solution and have an updated example. (itās currently at RN50). Perhaps just having a proper example for each version will alleviate all the issues popping up because this library doesnāt work with this version.
Thanks. It works
Chiming in here because this issue was invaluable in helping me to upgrade to
0.60.5
(and at this point I have this working in plist and in javascript):If you remove preprocessor settings, donāt expect any variables in your plist file to work. I did this because I simply needed my app to build so I could move onto other dependencies.
If you want to use variables in your plist and need to remove the preprocessor steps to get your app to run, make sure to follow @s123121ās steps above.
NOTE: the readme is different from comments here that Iāve gotten to work, specifically the line:
${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
The README has the first operation in quotes which wasnāt getting there for me, when I used the one posted by @ninjz this finally worked.
If you are using Pods just add (without
react-native link react-native-config
)pod 'react-native-config', :path => '../node_modules/react-native-config/react-native-config.podspec'
in your Podfile@mehdihz npm version?
Credit goes to @bockc here https://github.com/prscX/react-native-toasty/issues/12#issuecomment-514209713
I ended up using this specific commit and then I didnāt need the post-install scripts mentioned in other issues github.com/luggit/react-native-config.git#89a602b
Canāt seem to get this running either. Followed various options from above and none have worked. Got the same error as @kdenz when I tried his one.
Iāll see if I can get it going with a react-native init and see if I can figure out whatās going on from there.