feat(ios): allow for custom project dir in react-native-xcode script#35449
feat(ios): allow for custom project dir in react-native-xcode script#35449itxch wants to merge 3 commits into
Conversation
|
Hi @itxch! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 6003e70 |
Base commit: 6003e70 |
|
PR build artifact for 62bbc96 is ready. |
|
PR build artifact for 62bbc96 is ready. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Hi @itxch, I recently got something merged in regards to fixing our monorepo setup and it was resolved with this merge here: 4d7ddd4 What I find interesting about this PR is the When I see When I see you are using that to just compound onto Since I think the only change we might need here is just an easier documented source of why you would change |
|
Thanks for the reply @iBotPeaches
Thanks :) coming from the react web world, I love
I didn't realise that |
|
Was able to easily set PROJECT_DIR in Will update PR to just have some documentation around this - I'd say a comment in the Thoughts @iBotPeaches |
Sounds like a plan. Glad it worked out |
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Thank you so much for taking care of this. We would like to end up in a world where it's very easy to configure React Native and this PR goes in that direction! :D I imported the PR to keep an eye on it, but I agree with the suggested changes. I'll wait to land it until those are carried out. |
|
Updated the PR: react-native/packages/rn-tester/.xcode.env Lines 13 to 16 in 7db8204 To be honest line 16 could probably be uncommented, as its a good default I feel like. Whats your thoughts? |
|
PR build artifact for 7db8204 is ready. |
|
PR build artifact for 7db8204 is ready. |
Jumping on this as Riccardo is off for some days. |
Sure, we can keep it commented - its only required for monorepos |
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request was successfully merged by @itxch in 436da18. When will my fix make it into a release? | Upcoming Releases |
Summary
The
react-native-xcodescript assumes the thatnode_modulesfolder are in the same location as the react native project. This adds the ability to declareCUSTOM_DIRin.xcode.envfile to let react-native-xcode know where the react native project is located - required for monoreposIssue
At the moment if a project is not using the default react native file structure then when trying to create a build or archive using Xcode it will fail, with the following error:
Background
My project is a monorepo, using
npmworkspaces.This is the relevant file structure
This file structure is incompatible with line 63 of
react-native-xcode.shreact-native/scripts/react-native-xcode.sh
Line 63 in c5a8425
Note:
$REACT_NATIVE_DIRis thereact-nativepackage directory inside node modules.So by default this sets project root to be the parent folder of the
node_modulesfolder. However in my case this is not correct, it should actually be:PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../../app"}Solution
Seeing as hardcoding the value would not work, the simplest solution is to set the directory via a variable
PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../../$CUSTOM_DIR"}$CUSTOM_DIRcan easily be set via.xcode.envfile.Changelog
[IOS] [Added] - allow for custom project dir in react-native-xcode script
Test Plan
After updating my
.xcode.envfile to includeexport CUSTOM_DIR=app, I can successfully create a build or an archive.If the variable is not set it will be black, so it will not effect
$PROJECT_ROOT