[React Native] init cocoapods 미설치 오류

정까치·2022년 2월 7일
0

M1 맥북에서 react native 프로젝트 생성(init)시에 cocoapods이 있는데도 불구하고 아래와 같은 에러가 발생하는 문제에 대해 해결방법을 정리한다.

에러내용은 아래와 같다.

...
...
Run `npm audit` for details.
info Installing required CocoaPods dependencies
✖ CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary for the iOS project to run correctly. Do you want to install it? › Yes, with gem (may require sudo)
...
...

먼저 cocoapods에 관한 모든 내용을 삭제해보았다.

% gem list cocoa

*** LOCAL GEMS ***

cocoapods (1.11.2)
cocoapods-clean (0.0.1)
cocoapods-core (1.11.2)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.5.1)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
cocoapods-try (1.2.0)

% sudo gem uninstall cocoapods 
Password:
Remove executables:
	pod, sandbox-pod

in addition to the gem? [Yn]  y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.11.2
% sudo gem uninstall cocoapods-clean
Successfully uninstalled cocoapods-clean-0.0.1
% sudo gem uninstall cocoapods-core 
Successfully uninstalled cocoapods-core-1.11.2
% sudo gem uninstall cocoapods-deintegrate
Successfully uninstalled cocoapods-deintegrate-1.0.5
% sudo gem uninstall cocoapods-downloader 
Successfully uninstalled cocoapods-downloader-1.5.1
% sudo gem uninstall cocoapods-plugins   
Successfully uninstalled cocoapods-plugins-1.0.0
% sudo gem uninstall cocoapods-search 
Successfully uninstalled cocoapods-search-1.0.1
% sudo gem uninstall cocoapods-trunk 
Successfully uninstalled cocoapods-trunk-1.6.0
% sudo gem uninstall cocoapods-try  
Successfully uninstalled cocoapods-try-1.2.0

% gem list cocoa

*** LOCAL GEMS ***

결과는 다음과 같이 실패하였다.

% react-native init asdf
...
...
✔ CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary for the iOS project to run correctly. Do you want to install it? › Yes, with Homebrew
/Users/*********/asdf/node_modules/metro-hermes-compiler/src/emhermesc.js:77
          throw ex;
          ^

RuntimeError: abort(Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd .//Users/*********/asdf/ios && pod install".
CocoaPods documentation: https://cocoapods.org/). Build with -s ASSERTIONS=1 for more info.
    at process.abort (/Users/*********/asdf/node_modules/metro-hermes-compiler/src/emhermesc.js:440:13)
    at process.emit (node:events:520:28)
    at emit (node:internal/process/promises:133:20)
    at processPromiseRejections (node:internal/process/promises:260:27)
    at processTicksAndRejections (node:internal/process/task_queues:97:32)
...
...

brew로 설치했으니 brew list로 확인해 볼 때 설치가 된 것은 확인할 수 있다.
하지만 또 다시 cocoapods를 설치할지 물어본다.

하나 이상한 점을 발견함.
brew, gem 둘다 pod을 삭제했는데도, pod 명령어가 되길래 which pod으로 검색해보았더니,
/usr/local/bin/ 안에 pod폴더가 있는 것을 확인함.
일단 해당 폴더를 수동으로 지웠음

sudo rm -rf /usr/local/bin/pod

brew로 설치하면 잘된다는 글을 본 것 같아, 모두다 지웠으니 brew로 설치

% brew install cocoapods
% pod --version
1.11.2

react native 실행해봤더니 설치가 되는 것 같다.
확인을 위해서는 다시 gem으로 설치해봐야 확실해지겠으나, 이건 추후 진행해야겠다....

그래서 마지막으로 정리하면, pod을 구석구석 잘 찾아내서 흔적들을 지워준 후, 최종적으로 brew로 설치하는 것이 깔끔하다.

profile
게임 회사에서 빅데이터 플랫폼을 개발하고 있는 4년차 개발자입니다 : )

0개의 댓글