react-native-config을 사용해보십시오. 여기에 react-native-config와 함께 Managing Configuration in React Native에 관한 좋은 기사가 있습니다.
또한 react-native-config를 사용하여 테스팅 중에 루프 애니메이션을 비활성화하는 방법에 대한 실제 예제를 사용하여 animated-button-block-the-detox 응답을 제공했습니다.
기본 아이디어는 모든 다른 빌드 환경 (개발, 생산, 테스트 등)에 대한 .env 구성 파일을 만드는 것입니다. 이것들은 Javascript, Objective-C/Swift 또는 Java에서 액세스 할 수있는 구성 변수를 보유합니다.
$ ENVFILE=.env.staging react-native run-ios # bash
그리고이 package.json 파일의 예입니다 해독을 위해 .env의 설정 파일을 사용 당신은 다음 응용 프로그램을 빌드 할 때 사용할 설정 파일을 .env의 지정
가
앱 만들기
"detox": {
"specs": "e2e",
"configurations": {
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/example.app",
"build": "ENVFILE=.env.production export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/example.xcodeproj -scheme example -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 5s, iOS 10.3"
},
"ios.sim.test": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
"build": "ENVFILE=.env.testing xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build -arch x86_64",
"type": "ios.simulator",
"name": "iPhone 5s, iOS 10.3"
}
}
}