[英]Xcode 12.4 React native build failed in IOS Showing All Messages Command PhaseScriptExecution failed with a nonzero exit code
i am new in react native i want to run react native app in IOS after react-native init, app not run in IOS show some error Showing All Messages bash: Native/social_login/socialLogin/node_modules/react-native/scripts/../Libraries: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code and build failed please help me versions我是本机反应的新手我想在 react-native 初始化后在 IOS 运行本机应用程序,应用程序未在 IOS 中运行显示一些错误显示所有消息 bash: Native/social_login/socialLogin/node_modules/react-native/scripts/../Libraries : 没有这样的文件或目录Command PhaseScriptExecution 因非零退出代码而失败并且构建失败请帮助我版本
"react": "17.0.1", "react-native": "0.64.0" command line tools: Xcode 12.4 (12D4e) “react”:“17.0.1”,“react-native”:“0.64.0” 命令行工具:Xcode 12.4 (12D4e)
This happened also to me upgrading from 0.63 to 0.64.这也发生在我从 0.63 升级到 0.64 的身上。 After trying all solutions I followed a solution moving the folder to a directory where the path contain no spaces and it works and build the app successfully.
在尝试了所有解决方案后,我遵循了一个解决方案,将文件夹移动到路径不包含空格的目录,并且它可以正常工作并成功构建应用程序。
Solution to React Native 0.64 build fail React Native 0.64 build 失败的解决方法
In order for this to work properly follow these steps:为了使其正常工作,请执行以下步骤:
Crazy and absurd that a space in the path-name could cause this issue路径名中的空格可能会导致此问题,这很疯狂和荒谬
Try to run pod install
in ios folder尝试在 ios 文件夹中运行
pod install
cd ios && pod install
Then when it's done go back to your main folder and run然后当它完成 go 回到你的主文件夹并运行
yarn run ios
If that doesn't work, check out the solutions here如果这不起作用,请在此处查看解决方案
Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Xcode 10.2.1 命令 PhaseScriptExecution 失败,退出代码为非零
There seems to be an issue with coreutils
on macOS. macOS 上的
coreutils
似乎存在问题。
What fixed it for me is:为我解决的问题是:
brew install coreutils
brew install findutils
brew install gnu-sed
Finally change the node_modules/react-native/scripts/generate-specs.sh
to:最后将
node_modules/react-native/scripts/generate-specs.sh
更改为:
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# This script collects the JavaScript spec definitions for core
# native modules and components, then uses react-native-codegen
# to generate native code.
#
# Optionally, set these envvars to override defaults:
# - SRCS_DIR: Path to JavaScript sources
# - CODEGEN_MODULES_LIBRARY_NAME: Defaults to FBReactNativeSpec
# - CODEGEN_MODULES_OUTPUT_DIR: Defaults to React/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_MODULES_LIBRARY_NAME
# - CODEGEN_COMPONENTS_LIBRARY_NAME: Defaults to rncore
# - CODEGEN_COMPONENTS_OUTPUT_DIR: Defaults to ReactCommon/react/renderer/components/$CODEGEN_COMPONENTS_LIBRARY_NAME
#
# Usage:
# ./scripts/generate-specs.sh
# SRCS_DIR=myapp/js CODEGEN_MODULES_LIBRARY_NAME=MySpecs CODEGEN_MODULES_OUTPUT_DIR=myapp/MySpecs ./scripts/generate-specs.sh
#
# shellcheck disable=SC2038
set -e
THIS_DIR=$(cd -P "$(gdirname "$(greadlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
TEMP_DIR=$(gmktemp -d /tmp/react-native-codegen-XXXXXXXX)
RN_DIR=$(cd "$THIS_DIR/.." && pwd)
# find node path
source "$RN_DIR/scripts/find-node.sh"
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
USE_FABRIC="${USE_FABRIC:-0}"
cleanup () {
set +e
grm -rf "$TEMP_DIR"
set -e
}
describe () {
printf "\\n\\n>>>>> %s\\n\\n\\n" "$1"
}
main() {
SRCS_DIR=${SRCS_DIR:-$(cd "$RN_DIR/Libraries" && pwd)}
CODEGEN_MODULES_LIBRARY_NAME=${CODEGEN_MODULES_LIBRARY_NAME:-FBReactNativeSpec}
CODEGEN_COMPONENTS_LIBRARY_NAME=${CODEGEN_COMPONENTS_LIBRARY_NAME:-rncore}
CODEGEN_MODULES_OUTPUT_DIR=${CODEGEN_MODULES_OUTPUT_DIR:-"$RN_DIR/React/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_MODULES_LIBRARY_NAME"}
# TODO: $CODEGEN_COMPONENTS_PATH should be programmatically specified, and may change with use_frameworks! support.
CODEGEN_COMPONENTS_PATH="ReactCommon/react/renderer/components"
CODEGEN_COMPONENTS_OUTPUT_DIR=${CODEGEN_COMPONENTS_OUTPUT_DIR:-"$RN_DIR/$CODEGEN_COMPONENTS_PATH/$CODEGEN_COMPONENTS_LIBRARY_NAME"}
TEMP_OUTPUT_DIR="$TEMP_DIR/out"
SCHEMA_FILE="$TEMP_DIR/schema.json"
if [ -z "$NODE_BINARY" ]; then
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
exit 1
fi
CODEGEN_PATH=$("$NODE_BINARY" -e "console.log(require('path').dirname(require.resolve('react-native-codegen/package.json')))")
# Special case for running CodeGen from source: build it
if [ ! -d "$CODEGEN_PATH/lib" ]; then
describe "Building react-native-codegen package"
bash "$CODEGEN_PATH/scripts/oss/build.sh"
fi
describe "Generating schema from flow types"
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
describe "Generating native code from schema (iOS)"
pushd "$RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$CODEGEN_MODULES_LIBRARY_NAME"
popd >/dev/null || exit 1
describe "Copying output to final directory"
gmkdir -p "$CODEGEN_COMPONENTS_OUTPUT_DIR" "$CODEGEN_MODULES_OUTPUT_DIR"
gcp -R "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME-generated.mm" "$CODEGEN_MODULES_OUTPUT_DIR" || exit 1
gfind "$TEMP_OUTPUT_DIR" -type f | gxargs gsed -i.bak "s/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_COMPONENTS_LIBRARY_NAME/g" || exit 1
gfind "$TEMP_OUTPUT_DIR" -type f -not -iname "$CODEGEN_MODULES_LIBRARY_NAME*" -exec cp '{}' "$CODEGEN_COMPONENTS_OUTPUT_DIR/" ';' || exit 1
echo >&2 'Done.'
}
trap cleanup EXIT
main "$@"
notice that some commands are starting with g
like greadlink
etc.请注意,某些命令以
g
开头,例如greadlink
等。
if your get invalid identifier
error in react-native-xcode.sh
then under Build Phases
-> Bundle React Native code and images
it should be: (notice the double quotes):如果您在
react-native-xcode.sh
中出现invalid identifier
错误,则在Build Phases
-> Bundle React Native code and images
下应该是:(注意双引号):
set -e
export NODE_BINARY="node ../node_modules/react-native/scripts/react-native-xcode.sh"
use patch-package react-native
to patch it (if project is being developed on different machines then they must install the brew packages above)使用
patch-package react-native
来打补丁(如果项目正在不同的机器上开发,那么他们必须安装上面的 brew 包)
This is nothing just an issue with the scheme name for me, in my case my scheme name contains whitespace eg "ABC staging", which is not allowed, it got fixed after deleting and creating a new scheme with the name "ABC-staging".这对我来说只是方案名称的问题,在我的情况下,我的方案名称包含空格,例如“ABC staging”,这是不允许的,它在删除并创建一个名为“ABC-staging”的新方案后得到修复.
in the case of react-native 0.67^, you may need to apply these changes as well对于 react-native 0.67^,您可能还需要应用这些更改
change line no 7
set -e. ==> set +e
in在
node_modules/react-native/scripts/find-node.sh
then use patch-package using the following command:然后使用以下命令使用补丁包:
npx patch-package react-native
this will create a patch file inside the patch folder in root, then you can add in the post-install script in package.json:这将在根目录下的补丁文件夹中创建一个补丁文件,然后您可以在 package.json 中添加安装后脚本:
"postinstall": "npx patch-package"
This command will run each time a new package is getting added to the project and auto-fix react-native find-node.每次将新的 package 添加到项目中并自动修复 react-native 查找节点时,都会运行此命令。 sh.
嘘。
Adding $(ARCHS_STANDARD)
to Valid Architectures in Build Settings solved it for me将
$(ARCHS_STANDARD)
添加到构建设置中的有效架构为我解决了这个问题
For me it was just having a space in folder name which was in the path of project folder from root.对我来说,它只是在文件夹名称中有一个空格,它位于根目录的项目文件夹路径中。
Ok, worth trying this.好的,值得一试。
As soon as we get this error message:一旦我们收到此错误消息:
Always scroll up & read the issue if written in that log file.如果写入该日志文件,请始终向上滚动并阅读问题。 Any issues like syntax error or issue related to your js code (like multiple imports in your js files or if you had forgot to import something).
任何问题,例如语法错误或与您的 js 代码相关的问题(例如您的 js 文件中的多个导入,或者您忘记导入某些内容)。 If yes, you can fix that first & re build it.
如果是,您可以先修复它并重新构建它。
In my case I had multiple imports of one of the RN components.就我而言,我多次导入其中一个 RN 组件。
I had to delete the contents of my ~/.bash_profile
file.我不得不删除
~/.bash_profile
文件的内容。
I don't even use bash, but some other script populated the file and that broke my build.我什至不使用 bash,但是其他一些脚本填充了该文件,这破坏了我的构建。 Deleting the contents fixed the build, immediately.
删除内容立即修复了构建。 Might not work for you, but thought I'd share.
可能不适合你,但我想我会分享。
I'm running Xcode 13.4.1我正在运行 Xcode 13.4.1
Installed cocoapods using brew install cocoapods ( https://brew.sh/index_es )使用brew install cocoapods 安装 cocoapods ( https://brew.sh/index_es )
M2 apple chip M2苹果芯片
React Native 0.70反应原生 0.70
Actually after spending a whole lot of time trying different solutions none of them worked except for Giuseppe's answer.实际上,在花了很多时间尝试不同的解决方案之后,除了 Giuseppe 的回答之外,它们都没有奏效。 I had white spaces in my path "/React Native/exampleProject"
我的路径“/React Native/exampleProject”中有空格
1. Renamed folders/files to remove any white space in the path (creating a fresh project within the fixed path worked with no problems at all) 1.重命名文件夹/文件以删除路径中的任何空白(在固定路径中创建一个新项目完全没有问题)
I didn't even had to execute pod install anymore in the ios folder我什至不必再在 ios 文件夹中执行pod install
In my case, i had to export the right path
to node
就我而言,我必须将正确的
path
导出到node
in your terminal type which node
, copy the path and export it in ios/xcode.env
在您的终端类型
which node
,复制路径并将其导出到ios/xcode.env
export NODE_BINARY="copied node path"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.