3
votes

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)

4

4 Answers

2
votes

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

2
votes

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

1
votes

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)

0
votes

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