main.jsbundle does not exist. this must be a bug with + echo 'react native

This issue take me some days to fixed. I got this issue when run the build on travis-ci. Here is my fix:

Add this line to scripts in your package.json file.

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

Now your can run the command to generate main.jsbundle. yarn build:ios or npm run build:ios

Open the Xcode > Select project target > add main.jsbundle to Copy Bundle Resource in Build Phases. (image below).

Xcode fix


Comment this line in AppDelegate.m

 jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 

Use this line:-

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 

After that run this to make jsbundle:-

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

Run after this command in xcode . Hope it will make bundle and there is no such error after that ... Thanx


This happens when there is no offline bundle file in your project, I had the same problem and this worked for me.

I have added the below line to my package.json file, under scripts section, so I don't have to type it every time I want to generate an offline bundle.

"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 run this command in your application projects folder:

npm run build:ios

After running the above command, new main.jsbundle will be generated in your ios/YourAppName directory.

Next, open your project using XCode, right click on your project name then click Add Files to "YourProjectName", choose the main.jsbundle file that was generated, and then build again.

Now it might be working well.

I am using:

 "react": "16.0.0-alpha.12",
 "react-native": "^0.48.3",

You need to run the following command:

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

After that, the app with the static bundle is installed on the real device. But because the nature of the static file, whenever I modify the source code, I need to run that command again to reflect the changes. (You can see next error in command)