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 terminalreact-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 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).
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",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With