Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I tried to archive my react native project using Product > Archive on XCode9.2. But Xcode produce this error:

File /Users/louis/Library/Developer/Xcode/DerivedData/Scavenger-evyvzocndqoghkclcbwewolywniz/Build/Products/Release-iphoneos/Scavenger.app/main.jsbundle does not exist. This must be a bug with


My Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.3.0
  npm: 5.5.1
  Watchman: 4.7.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.0.0 => 16.2.0
  react-native: ^0.50.3 => 0.50.4

I also tried to run on terminal
react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/Scavenger/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'but ended up with error Loading dependency graph... Unexpected end of JSON input

XCode error.

Click here to see XCode error

like image 314
Louis Kurniawan Avatar asked Mar 27 '18 06:03

Louis Kurniawan


3 Answers

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

like image 194
Cuong Lam Avatar answered Oct 16 '22 23:10

Cuong Lam


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

like image 32
Kartik Shah Avatar answered Oct 17 '22 01:10

Kartik Shah


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",
like image 24
Nidhi Shah Avatar answered Oct 17 '22 00:10

Nidhi Shah