expo go 앱에서는 이상 없이 돌아갔지만 testflight를 실행하면 앱이 실행되자마자 강제종료되었다.
앱 충돌이 있다고 한다.
충돌 로그를 살펴봐도 검색해도 근본적인 해결책을 찾지 못했다. 혹자는 app.json에 googleMapApiKey가 없어도 충돌이 난다고 했지만 내 원인은 이게 아니었다.
expo-constants를 잘못 사용한 것
에러가 났던 코드는 다음과 같다.
/*****************************
* environment.js
* path: '/environment.js' (root of your project)
******************************/
import Constants from "expo-constants";
import { Platform } from "react-native";
const url_ec = ""
const url_ec_test = ""
const localhost =
Platform.OS === "ios" ? "localhost:8080" : "10.0.2.2:8080";
const ENV = {
dev: {
apiUrl: url_ec_test
},
staging: {
apiUrl: url_ec
},
prod: {
apiUrl:url_ec
}
};
const getEnvVars = (env = Constants.manifest2.releaseChannel) => {
// What is __DEV__ ?
// This variable is set to true when react-native is running in Dev mode.
// __DEV__ is true when run locally, but false when published.
if (__DEV__) {
return ENV.dev;
} else if (env === 'staging') {
return ENV.staging;
} else {
return ENV.prod;
}
};
export default getEnvVars;
이 코드를 다음과 같이 불러왔었다.
import getEnvVars from '../environmant';
const { apiUrl } = getEnvVars();
testFlight에서 실행하면 왜 이부분에 에러가 생기는지 모르겠다.
암튼 다음과 같이 코드를 바꿔서 해결했다.
/*****************************
* environment.js
* path: '/environment.js' (root of your project)
******************************/
import Constants from "expo-constants";
import { Platform } from "react-native";
const url_ec = ""
const url_ec_test = ""
const localhost =
Platform.OS === "ios" ? "localhost:8080" : "10.0.2.2:8080";
const ENV = {
dev: {
apiUrl: url_ec_test
},
staging: {
apiUrl: url_ec
},
prod: {
apiUrl:url_ec
}
};
const getEnvVars = ENV.prod;
export default getEnvVars;
import getEnvVars from '../environmant';
const { apiUrl } = getEnvVars;
에러 해결하느라 빌드를 자주해서 expo 유료결제를 했다. 안드로이드 1달러, ios 2달러라고 한다.
빌드를 30회정도 한 끝에 에러를 찾을 수 있었다. 돈아깝다 시@봉방거