main.jsbundle does not exist. this must be a bug w

2020-02-23 06:43发布

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

11条回答
手持菜刀,她持情操
2楼-- · 2020-02-23 06:54

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)

查看更多
走好不送
3楼-- · 2020-02-23 06:56

Simply cleaning the project in Xcode helped me

查看更多
相关推荐>>
4楼-- · 2020-02-23 06:57

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",
查看更多
淡お忘
5楼-- · 2020-02-23 07:01

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

查看更多
等我变得足够好
6楼-- · 2020-02-23 07:01

Problem solved after I rewrite shell script. Project > Build Phases > Bundle React Native code and images. There was blank space character in the script.

查看更多
欢心
7楼-- · 2020-02-23 07:01

In my case this was caused by a space character in my project path: /users/USER/Projects/Project HousePlants/

That space in Project Houseplants the bundle can not handle and therefore can not find your main.jsbundle

Make sure that you have no whitespace characters in your path and try again.

See this answer

查看更多
登录 后发表回答