11<h1 align =" center " >React Native Config</h1 >
22
33<p align =" center " >Module to expose config variables to your javascript code in React Native, supporting both iOS and Android.</p >
4- <p align =" center " >Bring some [12 factor]( http://12factor.net/config) love to your mobile apps!</p >
5- <p align =" center " >Forked from [luggit's repo]( https://github.com/luggit/react-native-config) </p >
4+ <p align =" center " >Bring some < a href = " http://12factor.net/config " >12 factor</ a > love to your mobile apps!</p >
5+ <p align =" center " >Forked from < a href = " https://github.com/luggit/react-native-config " >luggit's repo</ a > </p >
66
77<p align =" center " >
88
@@ -86,14 +86,15 @@ pod install
8686
8787 # react-native-config codegen
8888 ios/react-native-config.xcconfig
89+ ios/envfile
8990 ```
9091
9192- In the Xcode menu, go to Product > Scheme > Edit Scheme
9293- Expand the "Build" settings on left
9394- Click "Pre-actions", and under the plus sign select "New Run Script Action"
9495- Where it says "Type a script or drag a script file", type:
9596 ```
96- ENVFILE= .env ${SRCROOT}/../node_modules/@bam.tech/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb ${SRCROOT}/.. ${SRCROOT}/react-native-config.xcconfig
97+ echo " .env.development" > " ${SRCROOT}/envfile"
9798 ```
9899
99100### Optional : Multi-environment support
@@ -114,7 +115,7 @@ For each environment, use the following step (and change `ANOTHER_ENV` by your e
114115## Javascript
115116
116117``` js
117- import Config from ' @bam.tech/react-native-config' ;
118+ import Config from " @bam.tech/react-native-config" ;
118119
119120Config .API_URL ; // 'https://myapi.com'
120121Config .GOOGLE_MAPS_API_KEY ; // 'abcdefgh'
@@ -195,12 +196,12 @@ export default {
195196``` js
196197// __mocks__/@bam.tech/react-native-config.js
197198
198- import fs from ' fs ' ;
199- import path from ' path' ;
199+ import fs from " fs " ;
200+ import path from " path" ;
200201
201- import dotenv from ' dotenv' ;
202+ import dotenv from " dotenv" ;
202203
203- const buf = fs .readFileSync (path .resolve (__dirname , ' .. ' , ' .. ' , ' .env' ));
204+ const buf = fs .readFileSync (path .resolve (__dirname , " .. " , " .. " , " .env" ));
204205const config = dotenv .parse (buf);
205206
206207export default config ;
0 commit comments