5
votes

I'm trying to publish my first React Native app in App store and when I'll build in Xcode:
Product > Archive
appears some error, but i already have main.jsbundle

main.jsbundle does not exist. This must be a bug with

  • echo 'React Native

Screen Error:

Screen Error

5

5 Answers

6
votes

You can generate a new main.jsbundle using this command.

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

Run this command in your project directory.

4
votes

In my case, I was able to fix the issue by removing main.jsbundle from Bundle Resources.

  • Open react native project in xcode
  • Check if Copy Bundle Resources build phase contains main.jsbundle
  • If it contains, remove it and build again

enter image description here

1
votes
  1. Clear watchman watches:
watchman watch-del-all
  1. Delete node_modules:
rm -rf node_modules and run yarn install
  1. Reset Metro's cache:
yarn start --reset-cache
  1. Remove the cache:
rm -rf /tmp/metro-*
0
votes

In Xcode, you should be able to find the main.jsbundle inside the Xcode project sidebar.

Xcode with main.jsbundle

  • If it isn't there, then you should drag the main.jsbundle into your Xcode project (in the default template app you can find it at ios/main.jsbundle)

  • If it is in there, but red - then you need to build a copy of the main.jsbundle which you can do via react-native bundle (and some additional args which you can look up.

0
votes

I was getting the error because of a bug in the code, instead of using simulator I was using Xcode to install a release build to my device which led to this error.

To fix this, run the app on the simulator make sure it builds and runs properly and then install it on your device.