React Native iOS 빌드에서 Podfile.lock 누락과 Xcode 시뮬레이터 오류 해결
Issue
섹션 제목: “Issue”React Native로 iOS 빌드를 진행하던 중 아래 두 가지 에러로 실행에 실패했다.
error Could not find "Podfile.lock"
error Could not get the simulator list from Xcode.npm run ios 로그를 보면 CocoaPods 쪽과 Xcode simulator 쪽에서 각각 문제가 발생하고 있었다.
$ npm run ios
error Could not find "Podfile.lock" at /${PROJECT_PATH}/ios/Podfile.lock. Did you run "pod install" in iOS directory?info Found Xcode project "${APP_NAME}.xcodeproj"xcrun: error: unable to find utility "simctl", not a developer tool or in PATHerror Could not get the simulator list from Xcode.Error: Command failed: xcrun simctl list --json devices즉 한 번의 빌드 실패 안에 두 가지 문제가 섞여 있었다.
Cause
섹션 제목: “Cause”1) Could not find "Podfile.lock"
섹션 제목: “1) Could not find "Podfile.lock"”iOS 의존성 설치가 완전히 끝나지 않았다.
Pod 관련 에러는 이번이 처음이 아니었다. React Native 프로젝트를 처음 생성할 때도 CocoaPods 설치가 실패한 적이 있었고, 당시에는 ios 디렉토리에서 pod install만 수동으로 실행해 임시로 넘겼다.
이번 환경에서는 Podfile.lock이 정상적으로 생성되지 않았거나, 의존성 설치가 중간에 멈춘 상태일 수 있었다.
2) Could not get the simulator list from Xcode.
섹션 제목: “2) Could not get the simulator list from Xcode.”
xcode-select가 가리키는 개발자 도구 경로가 Xcode IDE 쪽이 아니었다.
로그에 나온 simctl은 Xcode simulator를 다룰 때 쓰는 명령이다.
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH당시 환경에서는 기존에 설치돼 있던 Xcode Command Line Tools와 새로 설치한 Xcode IDE의 경로가 달랐고, xcode-select는 여전히 이전 경로를 가리키고 있었다.
$ xcode-select -print-path/Library/Developer/CommandLineTools반면 실제 Xcode IDE 경로는 아래였다.
/Applications/Xcode.app/Contents/Developer이번 환경에서는 simctl을 찾지 못해 simulator 목록을 읽어오지 못할 수 있었다.
Resolution
섹션 제목: “Resolution”1) CocoaPods를 다시 설치한다
섹션 제목: “1) CocoaPods를 다시 설치한다”먼저 ios 디렉토리로 이동해 CocoaPods 설치를 다시 시도했다.
$ cd ios$ pod install이 과정에서 바로 설치가 끝나지 않고, FlipperKit 관련 의존성을 찾지 못하는 에러가 다시 나왔다.
[!] CocoaPods could not find compatible versions for pod "FlipperKit"로그에 나온 가이드대로 Pod spec repo를 먼저 업데이트한 뒤 다시 설치했다.
$ pod repo update$ pod install그 뒤에는 Pod installation complete!가 출력되면서 iOS 의존성 설치가 정상적으로 끝났다.
2) Xcode 개발자 도구 경로를 바꾼다
섹션 제목: “2) Xcode 개발자 도구 경로를 바꾼다”그다음 xcode-select가 가리키는 경로를 Xcode IDE 쪽으로 바꿨다.
$ xcode-select -print-path/Library/Developer/CommandLineTools
$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
$ xcode-select -print-path/Applications/Xcode.app/Contents/Developer이후 다시 iOS 빌드를 실행했다.
$ npm run ios그 결과 Xcode workspace를 기준으로 빌드가 정상적으로 진행됐고, simulator 실행도 성공했다.
즉 이번 케이스에서는 Podfile.lock 문제와 Xcode simulator 문제가 각각 별개였고, CocoaPods 설치 상태와 xcode-select 경로를 모두 바로잡아야 iOS 빌드가 정상화됐다.
Notes
섹션 제목: “Notes”1) Podfile.lock 에러는 의존성 설치 상태를 먼저 의심한다
섹션 제목: “1) Podfile.lock 에러는 의존성 설치 상태를 먼저 의심한다”Did you run "pod install" in iOS directory?가 나오면ios디렉토리에서pod install부터 다시 확인하는 편이 빠르다.pod install중간에 버전 충돌이나 repo 업데이트 문제가 있으면Podfile.lock이 기대대로 준비되지 않을 수 있다.
2) simctl 에러는 xcode-select 경로도 같이 본다
섹션 제목: “2) simctl 에러는 xcode-select 경로도 같이 본다”Could not get the simulator list from Xcodeunable to find utility "simctl"
이 두 문장이 같이 보이면, Xcode 자체보다 먼저 xcode-select -print-path 결과를 확인하는 편이 좋다.
3) React Native iOS 빌드에서 같이 확인할 것
섹션 제목: “3) React Native iOS 빌드에서 같이 확인할 것”ios/Podfile.lock이 존재하는지pod install이 끝까지 성공하는지xcode-select -print-path가 Xcode IDE 경로를 가리키는지- Xcode 실행 후 simulator를 직접 띄울 수 있는지