【React Naive】打包

一.iOS

1.生成jsbundle

根目录执行

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

2.导入jsbundle

采用引用的形式导入,这样不用每次生成jsbundle都导入一次。

3.代码中加载jsbundle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...
    
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"jsbundle"];
    _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    
    ...
}

4.打包

在Xcode中按正常原生项目流程打包 Product -> Archive

二.Android

1.打包

根目录执行

cd android && ./gradlew assembleRelease

2.安装到真机

adb install -r xxx.apk

2.打指定渠道包

./gradlew assemble渠道名Release

你可能感兴趣的:(【React Naive】打包)