🔨 npm run ios 빌드 에러 해결

새로 만든 React Native 프로젝트 빌드를 시도하던 중 npm run android는 정상 동작하지만 npm run iosnpx-react-native run-ios는 빌드 에러가 계속해서 동일하게 반환됩니다.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above 오류가 계속 반복되었습니다.

오류 로그

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

/Users/jamie/ReactNative/MyProject/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'Flipper-Glog' from project 'Pods')
/Users/jamie/ReactNative/MyProject/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'YogaKit' from project 'Pods')
/Users/jamie/ReactNative/MyProject/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'boost-for-react-native' from project 'Pods')
/Users/jamie/ReactNative/MyProject/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'Flipper-DoubleConversion' from project 'Pods')
/Users/jamie/ReactNative/MyProject/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.4, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'Flipper-PeerTalk' from project 'Pods')

2021-08-17 19:48:36.564 xcodebuild[16327:999717] [MT] DVTPlugInManager: Required plug-in compatibility UUID 42E1F17B-27B3-4DE8-92A8-DC76BA4F5921 for DVTCoreGlyphs.framework (com.apple.dt.DVTCoreGlyphs) not present
** BUILD FAILED **

The following build commands failed:
	Ld /Users/jamie/Library/Developer/Xcode/DerivedData/MyProject-ehvsxxfydgpmpachipjczqrnagpc/Build/Products/Debug-iphonesimulator/MyProject.app/MyProject normal (in target 'MyProject' from project 'MyProject')
(1 failure)

info Run CLI with --verbose flag for more details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MyProject@0.0.1 ios: `react-native run-ios`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the MyProject@0.0.1 ios script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jamie/.npm/_logs/2021-08-17T10_48_38_832Z-debug.log

이에 Exit status 1, This is probably not a problem with npm. There is likely additional logging output above 등을 수없이 검색하며 구글에서 동일한 빌드 오류시 소개하는 방법들을 직접 적용해보았지만 결국 podfile을 수정하니 간단히 해결되었습니다.

React Native 빌드 오류로 npm run ios 커맨드가 동작하지 않고 있다면 이 포스팅을 끝까지 참고하시기 바랍니다.

❌ 빌드 오류 해결 실패

아래는 실패한 방법들입니다. 여전히 npm run ios로 빌드하면 오류를 반환하며 완료할 수 없습니다.

❌ npm install

터미널로 프로젝트 폴더 진입

cd ~/MyProject

node_modules 폴더 삭제

rm -rf node_modules

npm 재설치

npm install

❌ pods 관련 폴더와 파일 삭제

터미널로 프로젝트 폴더 진입

cd ~/MyProject

node_modules 폴더 삭제

rm -rf node_modules

yarn.lock 파일 삭제

rm -r yarn.lock

프로젝트 폴더 내 ios 폴더 진입하여 pod 관련 파일 삭제

cd ios
rm -r podfile.lock
rm -r pods

패키지 매니저와 pod 재설치

yarn install && npx pod-install

하지만 모두 동작하지 않았습니다.

🎵 성공한 방법

📴 disable flipper line

프로젝트 파일/ios/Pods 경로로 접속하면 Pods.xcodeproj 파일을 확인할 수 있습니다. 이를 클릭하면 Xcode가 실행됩니다.

맥 React Native 빌드 에러 : npm run ios 오류

실행 후 좌측에서 podflie을 클릭하여 파일을 열고 코드 밑 부분을 확인합니다. 위 이미지는 이미 주석처리를 완료한 상태입니다.

Flipper 연결을 하지 않을 것이므로,

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.

바로 밑 줄부터 앞에 #를 붙여 모두 주석처리합니다.

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'Myproject' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'MyprojectTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  #use_flipper! 
  #  post_install do |installer|
  #    flipper_post_install(installer)
  #  end
end

이렇게 파일을 수정해준 뒤 저장하고 하단 독에 xcode를 우클릭하여 완전히 종료합니다.

다음 아래 코드를 순서대로 한 줄씩 입력합니다.

cd ios
pod deintegrate
pod install
npm cache clean --force
npm ios run

정상적으로 React Native 프로젝트 빌드 오류가 해결되어 npm run ios 가 정상적으로 동작합니다.

맥 React Native 빌드 에러 : npm run ios 오류

🚀 추가 오류

info Installing "/Users/Library/Developer/Xcode/DerivedData/Myproject-bonsxgjdoajlredyfjrixepmycvr/Build/Products/Debug-iphonesimulator/Myproject.app"
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):
Unable to lookup in current state: Shutdown
info Launching "org.reactjs.native.example.Myproject"
error Failed to launch the app on simulator, An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):
Unable to lookup in current state: Shutdown

code=405 와 같이 빌드 직전 shutdown 오류가 발생할 경우는 실행중인 Metro 터미널과 Xcode Simulator가 없는지 확인하고, 모두 완전히 종료한 후 다시 npm ios run 을 실행합니다.

참고 : https://velog.io/@yeseul/Mac-React-Native-%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-%EC%97%90%EB%9F%AC%ED%95%B4%EA%B2%B0