$ yarn add react-native-config
$ react-native link react-native-config
(cd ios; pod install)
Xcode에서 project's name -> Libraries -> Add Files to [your project's name] -> ReactNativeConfig.xcodeproj 추가
ReactNativeConfig.xcodeproj 경로: 프로젝트 -> node_modules -> react-native-config -> ios
Build Phases -> Link Binary With Libraries -> libReactNativeConfig.a 추가(+버튼 클릭)
Build Setting -> Header Search Paths -> $(SRCROOT)/../node_modules/react-native-config/ios/** (non-recursive)
+ include ':react-native-config'
+ project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
+ implementation project(':react-native-config')
}
+ import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage()
+ new ReactNativeConfigPackage()
);
}
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh
import Config from "react-native-config";
Config.API_URL; // 'https://myapi.com'
Config.GOOGLE_MAPS_API_KEY; // 'abcdefgh'