Command PhaseScriptExecution failed with a nonzero exit code 错误解决记录
xCode报这个错误,首先看是哪个文件报错,进入错误日志
/Users/fanvil/Library/Developer/Xcode/DerivedData。因为我这边是FBReactNativeSpec这个文件下的错误,所以很容易找到错误日志:/Users/fanvil/Desktop/iOS/Demo/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/react_native_pods_utils/script_phases.sh: line 22: [Codegen] [Error] Could not find node. It looks like that the .xcode.env or .xcode.env.local : command not found
这边日志写的很清楚,是找不到node。在命令行里输入node,但是却显示有。OK,那八成是路径的问题了。果然我用的brew命令直接安装的node,他默认安装在了/opt/homebrew/bin/node这个路径下,然后我删除了node,从Node.js官网直接下载包然后安装,node默认安装在了/usr/local/bin。运行xCode,没有报错,问题解决。
这个是Node.js的官网传送门。