Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
9ccde37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per CLI discussion here, we can safely revert this commit and just default:
@janicduplessis, can you help me understand why you didn't do that in the first place?
Today, the CLI doesn't really care where you call it. It will "assume" the root by traversing up the tree and stop at first
package.json
.So, in case the structure is
packages/mobile/some_weird_custom_structure/MyProject.xcodeproj
and JS files are atpackages/mobile/index.js
, Metro & CLI will set that one as a root.I just want to confirm that this is what you had in mind before moving further.
CC: @thymikee
9ccde37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also,
PROJECT_ROOT
is confusing here because CLI/Metro will resolve their own and not respect this one.9ccde37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I fine with this change.