After you've developed your app with react native, how do you publish it for your users? The release process of an app is no different: signing package, publish to each store these two steps. This article will share with you how to sign and package a react Native APP.
In this article I'll show you how to package and publish the React Native IOS App.
For the packaged React Native Android app, check out the signature pack apk for React Native release app
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:
React-NativeBundle--Entry-FileIndexios. 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:
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 a folder at the root of our project release_ios
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.
Then, modify the APPDELEGATE.M file and add the following code:
- (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... return YES;}
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:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ NSURL *jsCodeLocation; #ifdef DEBUG jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];#else jsCodeLocation = [CodePush bundleURL];#endif... return YES;}
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
To publish an iOS app we need a $99 account to upload the app to AppStore, or $299 for an enterprise account to post the app to a server in your company or to a third-party company.
Next, we need to apply for AppID? Create an app at tunes connect? A wrapper? A few big steps to submit your app to the App Store.
Because there are detailed instructions in the official documentation, I'm not going to repeat it.
React native release app packaged iOS app