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.
This commnad works for me.
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
ornpm run build:ios
Open the Xcode -> Select project target -> add
main.jsbundle
toCopy Bundle Resource
in Build Phases. (image below).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
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
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"
Remove pod and pod.lock and add again. (pod install)
Happy Coding :)
In my case I got this error at archive after updating from RN 0.53.3 to 0.55.4
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.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.