React Native 0.60 업그레이드 - AndroidX 마이그레이션 트러블슈팅
배경
프로젝트를 React Native 0.59에서 0.60으로 업그레이드했다. 0.60의 주요 변경사항은 AndroidX 마이그레이션, CocoaPods 기본 적용, 그리고 autolinking이었다. 가장 큰 문제는 역시 AndroidX였다.
마이그레이션 과정
1. jetifier 적용
기존 서드파티 라이브러리들이 아직 AndroidX를 지원하지 않아 jetifier를 사용했다.
npm install --save-dev jetifier
npx jetify
package.json에 postinstall 스크립트 추가:
{
"scripts": {
"postinstall": "jetify"
}
}
2. gradle.properties 설정
android.useAndroidX=true
android.enableJetifier=true
3. 빌드 실패 해결
react-native-camera 라이브러리에서 빌드 오류가 발생했다. 해당 라이브러리가 아직 AndroidX를 완전히 지원하지 않아서였다.
임시 해결책으로 android/build.gradle에 아래 추가:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
}
}
}
}
4. iOS CocoaPods
iOS는 상대적으로 순조로웠다. Podfile 생성 후:
cd ios
pod install
결과
AndroidX 마이그레이션이 생각보다 복잡했다. 특히 오래된 서드파티 라이브러리들의 호환성 문제가 컸다. 일부 라이브러리는 포크해서 수정하거나, 대체 라이브러리를 찾아야 했다.
autolinking은 편했다. 더 이상 react-native link를 수동으로 실행할 필요가 없어졌다.
다음 업그레이드부터는 마이너 버전부터 따라가는 게 나을 것 같다.