2

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)

  • I have created schema for my app then in build -> pre-actions. I click add new script and paste the following:
echo ".env.staging" > /tmp/envfile
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
  • then I go to info.plist and use $(MYENVVAR) to get value from .env file but it could not get any value. Has anyone ever faced it? my package json lock is "react-native-config": "0.11.7"

Happy to see any comments

Shiva
  • 11,485
  • 2
  • 67
  • 84
phon sokserey
  • 51
  • 1
  • 7
  • I notice that the docs you mentioned https://github.com/luggit/react-native-config#ios and the version you have installed are mismatched. – channa ly Apr 07 '20 at 10:04
  • 1
    How I can check if there are mismatched version? – phon sokserey Apr 07 '20 at 10:08
  • I too have tried installing the config file as per the above document, it works fine with Android platform but IOS facing the same issue as said above Client Id or other Api urls are not being fetched from .env file and value passed is undefined. – Ajay S Apr 18 '20 at 05:13
  • Also found a open issue for the repo https://github.com/luggit/react-native-config/issues/444 – Ajay S Apr 18 '20 at 05:15

1 Answers1

7

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"
Gev
  • 842
  • 4
  • 21