nx-react-native icon indicating copy to clipboard operation
nx-react-native copied to clipboard

main.jsbundle not found on CI build

Open monroeinstitute opened this issue 4 years ago • 7 comments

I'm trying to build an app on Bitrise - has anyone had success with that?

It is failing on the Xcode build because it can't find main.jsbundle.

In my research of other apps, they recommend running something like this

"build:ios": "react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/YourAppName/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"

And then adding the bundle to your xcode project.

But, that doesn't seem to recognize nx library imports.

Another thing I've tried is changing the bundle react native code and images step in xcode to this

cd $PROJECT_DIR/.. export NODE_BINARY=node export EXTRA_PACKAGER_ARGS='--entry-file apps/native/src/main.tsx' ./node_modules/react-native/scripts/react-native-xcode.sh < /dev/null

However, that also doesn't work.

Bitrise is trying to help me on this, but I think that this relates to the way nx builds or doesn't build the bundle. Does anyone here have experience building this for CI / CD yet?

monroeinstitute avatar Feb 11 '21 13:02 monroeinstitute

We've been struggling with something like this as well while trying to setup detox texting.

We ended up wrapping the ensure symlink function inside the nrwl/react-native plugin for our ci build (still not working with detox) to fix some of the dependency issues.

goofiw avatar Feb 14 '21 19:02 goofiw

Was this working with a normal React Native project? The Nx commands mostly just wrap around the normal React Native tools, with the exception that some paths are updated to support a monorepo structure.

jaysoo avatar Feb 19 '21 18:02 jaysoo

One thing to note is that we already generate the xcode project with the correct entry-file, so no modifications should be needed.

We're in the process of wiring up more e2e tests for this project so this should be solved soon.

jaysoo avatar Feb 26 '21 19:02 jaysoo

Hey any update to this? I found in my project that the reference in the Xcode project was broken, so it was pointing to the apps/my-app/iOS/main.jsbundle however the default bundle command produces the bundle at dist/apps/my-app/ios/main.bundle. Just tested this with a fresh NX workspace and react native app, can confirm it happens out of the box.

I fixed the reference to that locally, but still hitting an issue where the index.js entry file is not found when archiving/building for release, any ideas? I'm happy to PR the fixes/defaults to the plugin when I can get this last bit resolved.

jackgllghr avatar Apr 16 '21 16:04 jackgllghr

For anyone hitting this thread, the current implementation for Bundle React Native code and images worked for us:

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS='--entry-file apps/APP_NAME/src/main.tsx'
export ENTRY_FILE='src/main.tsx'
../node_modules/react-native/scripts/react-native-xcode.sh

There seems to be a mismatch between requirements based on react versions.

kristjanmik avatar May 12 '21 00:05 kristjanmik

Any update on this? I am having a similar issue.

If I live like this

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS='--entry-file apps/APP_NAME/src/main.tsx'
export ENTRY_FILE='src/main.tsx'
../node_modules/react-native/scripts/react-native-xcode.sh

I get an issue without a proper log. Basically saying that Script-00DD1BFF1BD5951E006B06BC.sh failed

If I update the node_modules 's path

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS='--entry-file ../../../apps/mobile/src/main.tsx'
../../../node_modules/react-native/scripts/react-native-xcode.sh

I got them the issue that main.jsbundle is not found.

rengil avatar Jul 08 '21 21:07 rengil

So, in the end this was because I wasn't building my bundle - I was using default actions, which do a yarn install, but that is not what we need. We need to build the bundles. The yarn action I am using now is

- content: "#!/usr/bin/env bash\n# fail if any commands fails\nset -e\n# debug log\nset -x\nyarn install --ignore-engines\n# Sync dependencies\nyarn nx build-android native \nyarn nx bundle-ios native"

Then, you need to check all Android and IOS paths - the defaults again don't work - because ours are nested at /apps/appname/ios etc - After I switched to doing the nx builds in yarn, the errors became clear enough (i.e. can't find this path) for me to start playing with path variables and getting them right.

justinhandley avatar Sep 04 '21 12:09 justinhandley