Hi I was trying to create a offline bundle for react native iOS for testing using the following code
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
After doing this I tried to run the app using the command react-native run-ios --configuration=release
once it is done the app opens and crashes instantly. So I used react-native run-ios
this time the app opens with the local development server, if I terminate the development server then I will be getting Unhandled JS Exception error. For Android I tried the following steps to make it work.
mkdir android/app/src/main/assets
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
Even if I terminate the local development server the app will work in Android. Any help for building offline bundle for iOS is appreciated.
Edit 1:
After bundling for iOS using the command
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
I'm able to generate main.jsbundle inside iOS directory and then followed the following steps.
Removed all the App Transport Security Settings
and added Allow Arbitrary Loads(true)
inside Info.plist file.
Edited the Run Edit Scheme to Release
Changed the jsCodeLocation from
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
to
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
After following the above steps I'm getting the following error
File /Users/jeffreyrajan/Library/Developer/Xcode/DerivedData/app_prod-fnewtufemaynsoedmhggmfjynoti/Build/Products/Release-iphonesimulator/app_prod.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native
Here is the screenshot of the whole error
Here is the project structure
Current Version:
It appears that the build script that runs the bundler command does not handle whitespace characters in file paths correctly. I can see from the screenshot you posted that the path to your project contains a space character in the React-Native Projects
directory.
If you rename the directory to e.g. React-Native-Projects
, the Archive build will work correctly.
In general, it's a good developer practice to limit directory and file names to alphanumeric characters, because many Unix tools require escaping other character types.
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