main.jsbundle does not exist. This must be a bug with'
Asked Answered
F

6

10

I keep getting this errror when i'm trying to run React native app from Xcode 13.3 .

if i run it from terminal ( react-native run-ios ) it works fine.

Please find enclosed error details.

>     > File /Users/Library/Developer/Xcode/DerivedData/appName-crvjvqqnpdxpwkfkxccvnxunhhkw/
Build/Products/Release-iphonesimulator/appName.app/main.jsbundle
> does not exist. This must be a bug with'
My Environment details

MAC OS - 12.3.1 (M1 chip)
Xcode - 13.3
command line tools - 13.3
RN version - 0.61.5

solutions i have tried upto now

npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

(Xcode) -Build Phases -> Bundle React Native code and images , change to

cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh

Please let me know how i can fix this error.

Floreated answered 11/4, 2022 at 9:42 Comment(2)
same situation for me. I was making build without problems. I have to add other project and change node version with brew, but I restored all and now I got the same error. Same versions too, except RN 0.62.2Rabaul
any solution?,.....Glossematics
O
15

Run

sudo xcode-select --reset

Then run (check if you use index.js or index.tsx or other)

npx react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle --assets-dest ios

main.jsbundle should appear in your ios folder.

enter image description here

Then you can add it to "Copy Bundle Resources"below section:

enter image description here enter image description here

Overboard answered 2/11, 2022 at 14:7 Comment(0)
T
1

This was resolve in 0.63.3. https://github.com/facebook/react-native/issues/29351

If you still have issue with higher version, pls try to run react-native bundle command manually.

Triviality answered 3/10, 2022 at 8:37 Comment(1)
Same issue with react-native 0.70.3.Overboard
S
0

I faced this issue when I updated node v18 from v16. Switching back to v16 fixed the error. React-native 0.62.2

Sweepstake answered 14/12, 2022 at 11:23 Comment(0)
E
0

This issue has gone on for years but the most common fix I find is the below.

Run this command at the project root level:

npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

Then in build phases in xcode > click 'copy bundle resources' > click the '+' symbol > click 'add other...' > select the newly generated main.jsbundle file in projectname/ios > and tick box for copy contents. Now clean build folder then archive again.

If you have Images also you'll need to add the folder for assets into the same location as the above.

Hope that helps :)

Extenuate answered 7/6, 2023 at 9:8 Comment(0)
W
0

I encountered this issue all of a sudden after ~1 year of development on a project, working in RN 0.71.6, currently on Version 14.3.1 (14E300c). I tried to upgrade to the latest version of v71 - RN 0.71.14, but the problem persisted. It seemed intuitive that since this issue 'crept in', simply refreshing my build environment should solve it.

I tried to reinstall all libraries to no avail. Cleaning the build folder also did not work.

Solution:
Delete the project state/metadata directory that contains the Build output folder.

By entirely deleting /Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>, I was able to build a completely fresh version of the app, and the problem with the missing main.js file was resolved.

Project settings/options are cached elsewhere, so there is no need to worry about losing these. You will need to re-index files though (for-example), and any other build-prep that your project would encounter with a fresh start on the repository.

Note:
When clearing the build folder via XCode, only the following directory is nuked: /Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>/Build/Product. And some contents of /Users/<username>/Library/Developer/Xcode/DerivedData/<app-id>-<unique-build-hash-id>/Build/Intermediates.noindex are modified.

For my case, the issue seemed to result in a corrupted or incorrect state persisted in the files generated by xcode that describe the project's build setup, which are not cleared when the build folder is cleared.

Wilcher answered 14/10, 2023 at 12:14 Comment(0)
F
0

This could be any number of things. Check your Xcode build logs to see why the bundle build failed. In my case, I had an import in my react code that wasn't resolving.

Fineness answered 26/10, 2023 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.