RN 打包

项目根目录下

创建文件夹release_ios
RN 打包_第1张图片
688D7EEB-A6B3-47E4-B881-69C8BD195B5C.png

2.终端

项目根目录 输入

:react-native bundle --entry-file index.ios.js --platform ios --dev false --bundle-output release_ios/main.jsbundle --assets-dest release_ios/
3.将文件移动到项目下


RN 打包_第2张图片
image.png
RN 打包_第3张图片
image.png

为蓝色图片

4添加copy bundle


RN 打包_第4张图片
image.png

5.代码修改

let RNBundel = Bundle.main.url(forResource: "release_ios/main", withExtension: "jsbundle")
 let rnView = RCTRootView(bundleURL: RNBundel,
                             moduleName: "mainhomePage",
                             initialProperties: nil,
                             launchOptions: nil)

你可能感兴趣的:(RN 打包)