-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[monorepo] bundling doesn't work (workaround available) #656
Comments
I have initialized a new project from |
@Esemesek just tried it with new project and it is working for me as well. So I am now trying to figure out if there are any specifics in my project causing this. As it is now:
Only difference compared vanilla "rn" project is that I'm within monorepo environment i.e.
But this was not an issue previously and I've been using CocoaPods for a few previous versions before. My project is updated to run export NODE_BINARY=node
../../node_modules/react-native/scripts/react-native-xcode.sh packages/myTestApp-app/index.js Same goes for referencing entries in - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#if DEBUG
return
[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/myTestApp-app/index"
fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
} Does anything jump to mind? If not, I will try to get small replica of my repo set up with that error, as my current one is private project. |
You're in a monorepo, that's very important information. If you run your RN app from root of the project, you'll currently need to add |
@thymikee yeh, not sure how I forgot to include that bit of info, my bad.
This setup works on |
@iljadaderko I am currently working with monorepo project. From my experience, it is better to
|
I'll give this approach a try, I think in rn 0.61 they got rid of haste, so Never the less, this seems to be specific to my project, so will keep digging. Just out of curiosity is your monorepo project working on 0.61rc @Esemesek ? |
@iljadaderko nope. We are using on |
Alright, I'll keep digging into my issue, will report here if I find anything interesting. Thank you for your time guys, this seems like something specific to my project. |
@iljadaderko I have the same issue (brunolemos/react-native-web-monorepo#16), how did you fix? |
@brunolemos move
I've been told better monorepo support is coming soon. |
I have the same setup as @brunolemos |
@devagul93 it's because of how CLI looks for deps to look for (takes those from package.json and from react-native.config.js). We want to come up with a more ergonomic solution. |
I'm sorry @devagul93 or @iljadaderko can you help me understand what you mean by "adding react-native to root package.json" |
Adjust the "dependencies": {
+ "react-native": "*",
"other-package": "1.2.3" |
@thymikee thanks! I'll give this a try right now and report back |
I misread your note. I thought you had this under "devDependencies" I have
And i'm still getting the |
Had the same issue on android, fixed by changing the
and create a
I never had the chance to check ios. |
The solutions found in react-native-community/cli#656 didn't help but setting PROJECT_ROOT in the build phase script worked.
I stumbled upon this issue and I think it's because in a monorepo the react-native-xcode.sh will set the root to root, where Reopening to fix. |
This comment has been minimized.
This comment has been minimized.
I've had to add export PROJECT_ROOT="$PROJECT_DIR/.." inside the xcode step |
It's alive!!! Thanks a lot |
thanks,solve my problem |
@Titozzz thanks, this iOS workaround helped. In my case for Android it was:
Because project structure is:
Also related issue #877 comment with same workadounds |
The solution for adding |
The source of errors is this line https://github.com/facebook/react-native/blob/master/scripts/react-native-xcode.sh#L59-L61 that assumes The solution is to explicitly |
Looks like we can safely revert this commit facebook/react-native@9ccde37 and things will work automatically without any For now, the correct way of configuring is to set:
in a monorepo. Please do not use the other workaround provided. It's wrong. |
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
I am going to continue the discussion over facebook/react-native@9ccde37 with @janicduplessis to understand whether we can safely remove it. |
If you're using previous workaround, please check how to migrate onto the standard and approved solution in this PR: brunolemos/react-native-web-monorepo#52 |
Invalid platform "ios" selected. and main.jsbundle does not exist https://github.com/react-native-community/cli/issues/656\#issuecomment-532235648
My current project structure of monorepo is:
react-native dependency is part of RN-app package.json. |
@grabbou, where do you add these lines?
|
@yaroslavnikiforov This is in the 'Bundle React Native code and images' build phase script in Xcode. You may not need to do it anymore though in a modern version of RN (and that script has changed a bit to call a |
@liamjones, great thanks! |
@liamjones I am running RN 71.7, and have the same issue: error Invalid platform "ios" selected I checked scripts/react-native-xcode.sh and it has the change that @grabbou gave: I didn't understand in your comment the jsBundleURLForBundleRoot part in AppDelegate. |
@giladm the AppDelegate edit we made is along the lines of:
That isn't your problem though (well, not yet). If it's complaining ios in an invalid platform then the RN CLI can't find the RN CLI iOS package. One has probably been hoisted to |
To kick off: I also posted clone of this issue in rn repo facebook/react-native#26259
Although I'm almost sure that it is related to cli somehow due to errors that get output. My instinct is either something changed to platform flag where
ios
value is invalid or due to usage of multiple cli paths while archiving. Full details below. If this does sound like a cli issue, I'll close one in rn, if not will do vice versa.React Native version:
Steps To Reproduce
Error
Towards the end of the build following error pops up, tried cleaning derived data and caches, but this happens consistently:
TL;DR I think actionable bits are
error Invalid platform "ios" selected.
andmain.jsbundle does not exist.
Also looks like cli commands are ran from different directories, both of these are present in the output:
/node_modules/react-native/cli.js
and/node_modules/@react-native-community/cli
I've started getting this error when I upgraded from
0.59
to0.61rc
. What confuses me is that my normal "DEBUG" builds are working fine.The text was updated successfully, but these errors were encountered: