From 9ccde378b6e6379df61f9d968be6346ca6be7ead Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 4 Feb 2019 07:46:14 -0800 Subject: [PATCH] Allow changing the project path in react-native-xcode.sh (#23273) Summary: When using react-native inside a monorepo with yarn workspaces the react-native installation can get hoisted and the assumption that the project is located in the folder where node_modules is is no longer true. To handle this case I added an option to pass the path of the project root. For example when using yarn workspace we can use something like this in the xcode scripts: Assumes the following folder structure /packages/myapp /node_modules/react-native ```sh export NODE_BINARY=node export PROJECT_ROOT=$PWD/.. ../../../node_modules/react-native/scripts/react-native-xcode.sh ``` It could be possible to change the default to `$PWD/..` since pwd is where the xcode project is located but then it would break if the native project structure is not the one we assume. To avoid the breaking change I decided to just keep the existing behaviour and allow changing the path with `PROJECT_ROOT`. [ios] [added] - Allow changing the project path in react-native-xcode.sh Pull Request resolved: https://github.com/facebook/react-native/pull/23273 Differential Revision: D13941793 Pulled By: cpojer fbshipit-source-id: f394641b1c9d01f32bc4169097e39fc14df8191f --- scripts/react-native-xcode.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 65404cc6864260..d684e89f8dc99d 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -53,9 +53,11 @@ esac # Path to react-native folder inside node_modules REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +# The project should be located next to where react-native is installed +# in node_modules. +PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../.."} -# Xcode project file for React Native apps is located in ios/ subfolder -cd "${REACT_NATIVE_DIR}"/../.. +cd $PROJECT_ROOT # Define NVM_DIR and source the nvm.sh setup script [ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"