React native release app packaged iOS app

Source: Internet
Author: User

First step: Export JS bundle and picture Resources

Unlike the packaged react Native Android app, we can't export react Native iOS apps with the command step. We need to package the JS part of the code with the image resource, and then add it to the iOS project through Xcode.

command to Export JS bundle

Under the root directory of the React native project:

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

With the above command, we can export the JS part of the Code and picture resources, such as packaging exported to the Release_ios directory:

Generate Jsbundle

Among them, assets for the project in the JS part of the image resources (not including the original module of the picture resources), Main.jsbundle is the JS part of the code.

Before we execute the package command, we need to make sure that we have the Release_ios folder at the root of our project and create one without it.

Step two: Import JS bundle and picture resources into iOS project

In this step we need to use Xcode, select the Assets folder and the Main.jsbundle file to drag it to the Xcode project navigation panel.

Import Jsbundle

Then, modify the APPDELEGATE.M file and add the following code:

12345678910 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{  NSURL *jsCodeLocation; //jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; +jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main"withExtension:@"jsbundle"];#endif...  returnYES;}

The function of the above code is to let react native to use the jsbundle we just imported, so we have been freed from the reliance on the local NODEJS server.

Tip: If you use the Codepush hot update in your project, then we need to be able to read the local jsbundle directly through Codepush, as follows:

1234567891011 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{  NSURL *jsCodeLocation;  #ifdef DEBUG    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios"fallbackResource:nil];#else    jsCodeLocation = [CodePush bundleURL];#endif...  returnYES;}

So far, we've imported JS bundle and image resources into our iOS project, and then we're ready to publish our iOS app.

Step three: Publish iOS apps

。。。

Original link

React native release app packaged iOS app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.