React Native 打包 iOS

1.在项目的 ios 目录下 新建 bundle 文件夹

2.在项目目录中运行以下命令

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle          
  • --entry-file             ios或者android入口的js名称 index.js
  • --platform             平台名称(ios或者android)
  • --dev                    设置为false的时候将会对JavaScript代码进行优化处理。
  • --bundle-output    生成的jsbundle文件的名称 ./ios/bundle/index.ios.jsbundle
  • --assets-dest        图片以及其他资源存放的目录 ./ios/bundle

 成功之后如下提示, 可以看到 ios/bundle 中已经生成了离线资源

 3. Add Files to ""

4.修改 AppDelegate.m 文件 把之前的 jsCodeLocation 注释就行

//开发环境
//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
//打包环境
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

5.修改release模式

6.开始打包 将模拟器调成 Generic iOS Device 然后 按 commd + b (看是否运行正常) , 可以的话点击 Archive 

7. 好了之后可以看到如下界面(Window => Organizer 可以打开此页面)首先 Validate App 验证 然后可以 上传到App store 或者其他

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值