phon sokserey
phon sokserey

Reputation: 51

react native config cannot read env file in ios

I have follow the doc: https://github.com/luggit/react-native-config#ios until: Availability in Build settings and Info.plist step 6. create new build phase for the scheme which will generate "tmp.xcconfig" before each build exposing values to Build Settings and Info.plist (this snippet has to be placed after "echo ... > tmp/envfile" if approach explained below is used)

echo ".env.staging" > /tmp/envfile
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"

Happy to see any comments

Upvotes: 2

Views: 11545

Answers (1)

Gev
Gev

Reputation: 882

If you can see empty config file in your JS when importing import Config from 'react-native-config' and 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.

And try to update module version

"react-native-config": "^1.0.0"

Upvotes: 7

Related Questions