Skip to content

Commit 9ccde37

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
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: #23273 Differential Revision: D13941793 Pulled By: cpojer fbshipit-source-id: f394641b1c9d01f32bc4169097e39fc14df8191f
1 parent 9f72e6a commit 9ccde37

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/react-native-xcode.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ esac
5353

5454
# Path to react-native folder inside node_modules
5555
REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
56+
# The project should be located next to where react-native is installed
57+
# in node_modules.
58+
PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../.."}
5659

57-
# Xcode project file for React Native apps is located in ios/ subfolder
58-
cd "${REACT_NATIVE_DIR}"/../..
60+
cd $PROJECT_ROOT
5961

6062
# Define NVM_DIR and source the nvm.sh setup script
6163
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

0 commit comments

Comments
 (0)