React Native/React Native_error

[React Native - ios] Command PhaseScriptExecution failed with a nonzero exit code

bocoder
728x90
반응형

* 동일한 소스로 여러 mac에서 yarn ios 커맨드 실행 시, 특정 mac 에서만 빌드가 실패함

 

# 에러 내용

...    
    export YACC\=yacc
    export arch\=undefined_arch
    export variant\=normal
    /bin/sh -c /Users/.../Library/Developer/Xcode/DerivedData/.../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-46EB2E000385F0.sh
Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **

The following build commands failed:
        PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/.../Library/Developer/Xcode/DerivedData/.../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-46EB2E000385F0.sh
(1 failure)

 

# 현상

특정 mac에서만 빌드를 실패하였기에 xcode 상의 설정값, 라이브러리 권한 등 환경설정 문제로 보임

 

# 해결

여러 시도 중 맨 아래의 6)번 방법으로 해결함

node 환경 설정이 문제인 것으로 추측됨

 

1) Podfile.lock, Pods, .xcworkspace 삭제 후 pod 재설치

$ cd {프로젝트명}/ios
$ rm -rf Podfile.lock Pods {프로젝트명}.xcworkspace
$ pod install

 

2) Script-46EB2E000385F0.sh 에 대한 권한 부여

$ chmod -x /Users/.../Library/Developer/Xcode/DerivedData/.../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-46EB2E000385F0.sh

 

3) pod cache clean 으로 캐시 제거

$ cd {프로젝트명}/ios
$ pod cache clean --all

 

4) nvm으로 node 설치한 경우 삭제 후 brew로 node 재설치

* reference : https://error-fighter.tistory.com/15?category=914504 

 

5) node_modules/react-native/scripts/find-node.sh 에 unset npm_config_prefix 추가

#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

# remove global prefix if it's already set
# the running shell process will choose a node binary and a global package directory breaks version managers
unset PREFIX
unset npm_config_prefix

...

* reference : https://github.com/react-native-community/upgrade-support/issues/138#issuecomment-1032782312

 

6) 상기 5번과 동일하게 node 환경설정 관련 이슈로 추측되어 find-node.sh 모두 주석 처리  --> 빌드 성공

# #!/bin/bash
# # Copyright (c) Meta Platforms, Inc. and affiliates.
# #
# # This source code is licensed under the MIT license found in the
# # LICENSE file in the root directory of this source tree.

# set -e

# # remove global prefix if it's already set
# # the running shell process will choose a node binary and a global package directory breaks version managers
# unset PREFIX

...

# # Set up the fnm node version manager if present
# if [[ -x "$HOME/.fnm/fnm" ]]; then
#   eval "$("$HOME/.fnm/fnm" env)"
# elif [[ -x "$(command -v brew)" && -x "$(brew --prefix fnm)/bin/fnm" ]]; then
#   eval "$("$(brew --prefix fnm)/bin/fnm" env)"
# fi

* reference : https://github.com/react-native-community/upgrade-support/issues/138#issuecomment-806831612

728x90
반응형