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 07:02

This commnad works for me.

react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle
查看更多
狗以群分
3楼-- · 2020-02-23 07:09

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

查看更多
家丑人穷心不美
4楼-- · 2020-02-23 07:10

Recommend to use the latest Xcode and React Native versions. My React Native Version: 0.56 and Xcode 10

Step 1: Change AppDelegate.m file

    //  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#ifdef DEBUG
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

Step 2: Change Xcode Build Configuration to "Release"

Goto Products> Scheme> Edit Scheme> change Debug to release

if you are using Xcode 10+ please change Build system to Legacy Build System under File> ProjectWorkSpace Settings> Build System

Step 3: Upgrade your "babel-preset-react-native" to 5.0.1, if it does not exist in your package.json file please add it.

Remove NodeModules and package.lock file and add it (npm install or yarn install).

Step 4: Change ".babelrc.js" file

Add " presets: ["module:metro-react-native-babel-preset"]

Step 5: Open Terminal

Open the terminal and navigate to your project directory run this command

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

this will generate a "main.jsbundle" file in iOS folder

Step 6: Add "main.jsbundle" file into Xcode.

Open Xcode and navigate to "Build Phase" under "Copy Bundle Resource" add "main.jsbundle" file.

Clean your project also clear your derived data in Xcode. This will build your project in Release mode.

For "Archive" error

Add this dependency into your "pod file"

pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'CxxBridge'
  ]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

Remove pod and pod.lock and add again. (pod install)

Happy Coding :)

查看更多
Bombasti
5楼-- · 2020-02-23 07:13

In my case I got this error at archive after updating from RN 0.53.3 to 0.55.4

/Users/<myuser>/Desktop/projects/<myProjectName>mobileapp/index.ios.js: Plugin 0 specified in "/Users/<myUserName>/Desktop/projects/<myProjectName>mobileapp/node_modules/babel-preset-react-native/index.js" provided an invalid property of "default" (While processing preset: "/Users/<myUserName>/Desktop/projects/<myProjectName>mobileapp/node_modules/babel-preset-react-native/index.js")

+ [[ false != true ]]
+ [[ ! -f /Users/<myUserName>/Library/Developer/Xcode/DerivedData/<myProjectName>Mobile-ghzbbftkebcwlvayfocqahvzifbe/Build/Intermediates.noindex/ArchiveIntermediates/<myProjectName>Mobile/BuildProductsPath/Release-iphoneos/<myProjectName>Mobile.app/main.jsbundle ]]
+ echo 'error: File /Users/<myUserName>/Library/Developer/Xcode/DerivedData/<myProjectName>Mobile-ghzbbftkebcwlvayfocqahvzifbe/Build/Intermediates.noindex/ArchiveIntermediates/<myProjectName>Mobile/BuildProductsPath/Release-iphoneos/<myProjectName>Mobile.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/<myUserName>/Library/Developer/Xcode/DerivedData/<myProjectName>Mobile-ghzbbftkebcwlvayfocqahvzifbe/Build/Intermediates.noindex/ArchiveIntermediates/<myProjectName>Mobile/BuildProductsPath/Release-iphoneos/<myProjectName>Mobile.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2

A big importance to fix this had the line above the error related to babel-preset-react-native

After many hours of trying several workarounds I found a solution by downgrading babel-preset-react-native from ^5.0.2 to ^4.0.0 to make the archive process work.

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

In my case, it was caused by the javascript code. The error showed at the Metro Bundler(Command Line). Check the Metro Bundler, Does it have an Error or not.

查看更多
登录 后发表回答