react native打包至真机测试

1.在自己项目的ios文件夹下新建一个文件夹取名bundle(ps:ios文件夹和node_modules文件夹在同一级目录下,这个bundle文件夹名称随意取,后面要用到,但是记得在相应地方改一下就好了)

2、package.json 文件 scripts 内加入

  

"bundle-ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle",

  

3.修改 根目录 .ios/项目名称/AppDelegate.m
 
  //电脑模拟器执行
  // jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  //真机执行
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"bundle/index.ios" withExtension:@"jsbundle"];

  

后期引用 

https://blog.csdn.net/birthmarkqiqi/article/details/73650844

猜你喜欢

转载自www.cnblogs.com/shihao905/p/9299213.html