💡Aha!

pod 명령어 사용 시 Bus Error

1❯ pod install
2[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
3Analyzing dependencies
4Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
5[Codegen] Found FBReactNativeSpec
6Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
7Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
8Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
9/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x00000001022ec000

어쩌다가 React Native를 하게 되어 ios 디렉터리에서 pod install 을 실행하였는데, 이상한 오류가 발생하였다.

실행 환경은 M1 Macbook Pro (2020), macOS Monterey 12.3.1에서 발생하였다.

해결법

아키텍쳐 관련 문제인 것으로 보이는데, homebrew 버전의 cocoapods은 해당 문제가 해결된 것으로 보인다.

1# gem으로 설치한 cocoapods 삭제
2sudo gem uninstall cocoapods
3
4# homebrew에서 cocoapods 설치
5brew install cocoapods

혹은 다른 해결법

예전에 M1 대응이 어려웠을 때 이용했던 방법이며, 현재는 cocoapods에서는 권장하지 않고 있다. 아키텍쳐 문제가 발생하는 경우에만 사용하자.

arch 명령어를 이용하여 x86_64 아키텍쳐로 gem을 실행한다. 따라서 로제타2가 머신에 깔려 있어야 동작한다.

1softwareupdate --install-rosetta

1sudo arch -x86_64 gem install ffi

다만 cocoapods에서는 해당 명령어를 이용하여 pod install을 하지 말라고 안내하고 있다.

1[!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).
2
3[!] - Emulated x86_64 is slower than native arm64
4
5[!] - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)
6
7[!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.

1arch -x86_64 pod install

2024 Dohyun Jung.
Made with ☕️.