4

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": "17.0.1", "react-native": "0.64.0" command line tools : Xcode 12.4 (12D4e)

12 Answers 12

5

This is nothing just an issue with the scheme name for me, in my case my scheme name contains whitespace e.g. "ABC staging", which is not allowed, it got fixed after deleting and creating a new scheme with the name "ABC-staging".

in the case of react-native 0.67^, you may need to apply these changes as well

In node_modules/react-native/scripts/find-node.sh, do

change line no 7 
set -e. ==> set +e 

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:

 "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. sh.

Sign up to request clarification or add additional context in comments.

Comments

3

This happened also to me upgrading from 0.63 to 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

In order for this to work properly follow these steps:

  • If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues (i.e. npm uninstall -g react-native-cli)
  • Move the project folder in a path with no spaces (i.e. ~/sub folder name/ReactNativeApp won't work till you have spaces in the path, so move in a path like ~/folder/ReactNativeApp)
  • Then cd into the project folder and upgrade react native to the latest version with npx react-native upgrade and resolve conflicts if any
  • After upgrading remove the node_modules folder and the yarn.lock from the root and the podfile.lock and Pods folder from ios subfolder
  • Then cd back to the root and run yarn install && npx pod-install
  • Now run again your app in Xcode or your IDE and it works

Crazy and absurd that a space in the path-name could cause this issue

3 Comments

this was the case for me. I skipped the first step, but it still solved the issue. Grazie mile Giuseppe!
This was the case for me as well, after renaming the project folder without spaces, and moving it into a path without spaces in pathname, did the trick
"Move the project folder in a path with no spaces" - This answer saves my day man, thank you Using: M1 Pro 2021, 16GB Ram & ReactNative version: 0.71.3
2

Try to run pod install in ios folder

cd ios && pod install

Then when it's done go back to your main folder and run

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

Comments

2

There seems to be an issue with coreutils on macOS.

What fixed it for me is:

  1. brew install coreutils
  2. brew install findutils
  3. brew install gnu-sed

Finally change the node_modules/react-native/scripts/generate-specs.sh to:


#!/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.

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):

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)

Comments

2

I'm running Xcode 13.4.1
Installed cocoapods using brew install cocoapods (https://brew.sh/index_es)
M2 apple chip
React Native 0.70

Actually after spending a whole lot of time trying different solutions none of them worked except for Giuseppe's answer. I had white spaces in my path "/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)

I didn't even had to execute pod install anymore in the ios folder

2 Comments

Damn man, I used M1 Pro and got the same issue. This answer saves my day man... Thank you
Bro you just saved my day, I've been trying to fix this issue for two days. I had a white space within my workspace path. Thank you.
1

In my case, i had to export the right path to node

in your terminal type which node, copy the path and export it in ios/xcode.env

export NODE_BINARY="copied node path"

1 Comment

you mean ios/.xcode.env
0

For me it was just having a space in folder name which was in the path of project folder from root.

Comments

0

I had to delete the contents of my ~/.bash_profile file.

I don't even use bash, but some other script populated the file and that broke my build. Deleting the contents fixed the build, immediately. Might not work for you, but thought I'd share.

Comments

0

Ok, worth trying this. (This usually happens if you had multiple imports or any imports missing)

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. If yes, you can fix that first & re build it.

In my case I had multiple imports of one of the RN components.

Comments

0

What works for me after trying multiple solutions?

Note: I clone the code from git to continue development. I use Yarn as a package manager and I start with Yarn installing node modules and install pod then run ios build and get this error.

Solution: for this particular project I tried to use NPM and it worked for me. as the previous developer used it with NPM

Comments

0

I was facing a similar issue, but after a lot of research, I found out the solution.

You just need to:

  • Open Xcode and go to the Build Phases under the target folder.
  • Expand "Bundle React Native code and images".

Then, check if node ../node_modules/react-native/scripts/react-native-xcode.sh is within double quotes or not.

set -e
export NODE_BINARY="node ../node_modules/react-native/scripts/react-native-xcode.sh"

It must be within double quotes.

Comments

-1

Adding $(ARCHS_STANDARD) to Valid Architectures in Build Settings solved it for me

1 Comment

Can you should be more descriptive ? what needs to be added and where ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.