React Native iOS 빌드 에러
최근 React Native 의 빌드 환경을 옮기면서 마주한 에러들을 간단히 정리한다. Intel 프로세서에서 Apple M1 프로세서로 옮기면서 생긴 에러들이 아닌가 하고 추정하고 있지만, 정확하지는 않다.
1. pod install
이 되지 않는다
아래와 같은 에러가 발생하며 pod install
이 진행되지 않 았다.
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.1/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.1/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.1/lib/ffi_c.bundle
아래의 명령어를 실행하면 해결할 수 있다.
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
이후부터는 그냥 pod install
을 써도 문제 없다.
(출처)
2. Xcode 빌드 에러: Library not found for -lBase64
이 문제는 Xcode에서 프로젝트를 열 때 *.xcodeproj
파일 대신 *.xcworkspace
파일을 여니 해결되었다. 이것은 M1과는 무관한 이슈 같다.
3. Xcode 빌드 에러: ios/main.jsbundle: No such file or directory
본래라면 자동 생성/갱신되는 것으로 알고 있는 ios/main.jsbundle
파일이 생성/갱신되지 않으면서 생긴 에러이다.
아래 명령어를 실행해서 ios/main.jsbundle
파일을 직접 생성하면 문제가 해결된다.
yarn react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
라이브러리를 추가/삭제할 때마다 항상 실행해주어야 한다는 것이다. 나중에 언젠가 React Native 에서 (자동으로 되도록) 패치를 내주지 않을까 싶다.
(출처)
4. Xcode 빌드 에러: PhaseSriptExecution failed with a nonzero exit code
빌드 target의 [Build Phases] 탭의 [Bundle React Native code and images] 항목에서 "For install builds only" 선택 항목을 체크하면 해결된다.
만약 Sentry 를 연동하고 있다면, [Upload Debug Symbols to Sentry] 항목에 대해서도 "For install builds only" 선택 항목을 체크하자.