react-native: iOS main.jsbundle does not exists – Bundle React Native code and images
Hello!
I have updated an app from react-native@0.55.4
to react-native@0.59.9
and I’m having problems with the iOS build step Bundle React Native code and images
. The problem is that when the build gets on this step on the CI machine, fails automatically throwing the following error:
'error: File /Users/travis/Library/Developer/Xcode/DerivedData/app-arslyffdnfsjkgdxahmrdswzporu/Build/Intermediates.noindex/ArchiveIntermediates/app/BuildProductsPath/Release-iphoneos/appName.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues'
What bothers me is the thing that I can make a bundle on the CI machine using the react-native bundle
command without any problems or issues So I can safely assume that there’s no problem with the bundle creation.
From what I’ve read at #18472, I tried the proposed solutions such as ensuring that the version of node it’s specified by nvm as default, tried to use another version of Xcode, tried to use a newer version of Node. Nothing fixed the problem. Also I’ve tried to debug the issue and seems that this command it’s not being executed. The thing is that this script itself doesn’t give any output of what happened on success or fail.
This is the error log:
React Native Environment
I’m running the builds on a Travis CI machine and before the bump to 0.59.9
this never happened.
info
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
Memory: 1.94 GB / 4.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.16.0 - ~/.yarn/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
Steps To Reproduce
- Run the following command:
xcodebuild -scheme projectName -project ./ios/projectName.xcodeproj -configuration Release -destination 'generic/platform=iOS' -archivePath /Users/travis/Library/Developer/Xcode/Archives/2019-07-06/AppName\ 2019-07-06\ 07.16.44.xcarchive -UseModernBuildSystem=NO archive | tee /Users/travis/Library/Logs/gym/AppName-projectName.log | xcpretty
Describe what you expected to happen:
I expect that the main.jsbundle
file is created successfully through the step of Bundle React Native code and images as it does if I do it manually using the react-native bundle
command.
Thanks 🙏
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 34 (9 by maintainers)
After debugging out the issue, I found the problem, leaving it here just in case could help anyone:
On Xcode at the
Bundle React Native code and images
Build Phase I’ve set up theNODE_BINARY
to the result ofwhich node
.Then the CI finds always the correct binary regardless the node install method.
Upgraded react native version to 0.63.0 and build failed. Tried all solutions here but no luck yet. 😭
@carloscuesta that didn’t work for me but removing the entire
Bundle React Native code and images
build phase did workif you are using module-resolver
cd $PROJECT_DIR/.. export NODE_BINARY=node ./node_modules/react-native/scripts/react-native-xcode.sh
Note that this might break if the source of this is a bug in 0.63.0, so you may need to undo this on a future release.
In my case, I found it’s because I’m using typescript.
Open Project > Build Phases > Bundle React Native code and images. Original look like this
this gives me this error: The resource
/Users/stanjhae/Desktop/*project-name*/index.js
was not foundApparently, by default it checks for an index.js file but since i’m using index.ts, it goes berzerk.
I explicitly stated it should use index.ts and everything works fine
I suggest just running the script in
Bundle React Native code and images
manually and seeing what the issue is.In my case the step had
../node_modules/react-native/scripts/react-native-xcode.sh
script. I ran this script and saw that it looked forindex.js
, but as I was using TypeScript and had called my fileindex.ts
and that was the reason why it failedAlso upgraded to 0.63.0 and started having this issue. I managed to get the bundle in by using this command:
react-native bundle --entry-file='index.js' --bundle-output='./ios/app/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
However, my archived app does not contain the assets from my src folder. Everything works fine on development build
I was stuck with this problem for a while but after taking a quick look to the
react-native-xcode.sh
file, I realised that you can set the $ENTRY_FILE variable in the build phase script, like this:In my case, I just set the
index.tsx
file as my entry file as you can see and everything worked fine.In my cases, I change crypto-js library version from 4.0.0 to 3.3.0 in package json and everything worked. main.jsbundle not a problem anymore
None of the above fixed it for me on 0.63.2, but it works with this PR, it’ll probably be released soon https://github.com/facebook/react-native/pull/29477
i know this is sounds silly but my
export NODE_BINARY=$(which node) …/node_modules/react-native/scripts/react-native-xcode.sh
that one has one dot (./node) before node, i didn’t pay attention, need to be double dot (…/node)
React Native Environment Info: System: OS: macOS 10.15.5 Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.5.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.5 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 11.6/11E708 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: ^0.59.10 => 0.59.10 npmGlobalPackages: react-native-cli: 2.0.1
Just plainly using
which node
@annieweyYes, I was having the exact same problem as you @jaumevn this solved the issue: https://github.com/facebook/react-native/issues/25522#issuecomment-509036251