美文网首页
关于IOS Hot Reloading 失败的问题

关于IOS Hot Reloading 失败的问题

作者: 使劲挤海绵 | 来源:发表于2018-07-11 23:14 被阅读143次

近日发现,RN运行在IOS手机上进行调试的时候发现:

  • 当点击屏幕的Reload按钮时可以正常刷新的。 Reload.png
  • 当点击Enable Hot Reloading的时候,
    Enable_Hot_Reloading.png

不仅程序不会立刻根据代码的改动显示效果,而且Macos的Xcode IDE工具一致报错下面的问题:

RN Macos卡机.png
接着Macos电脑的网络模块就卡死了,点击不了
Macos_Network_Iocn.png
  • 针对以上的问题,一直在排查是不是项目中的package.json文件添加了什么不正确的库,后面发现是因为RN对应的IOS工程的
    AppDelegate.png 文件中,在添加jsCodeLocation时候,少填写了
    ?platform=ios&dev=true"
    正确的写法,应该是下述的 jsCodeLocation=.......
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

jsCodeLocation = [
                    NSURL URLWithString:@"http://xx.xx.xx.xx:8081/index.ios.bundle?platform=ios&dev=true"];


 RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"jfclothshop"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

真正的原理还在排查中...

相关文章

网友评论

      本文标题:关于IOS Hot Reloading 失败的问题

      本文链接:https://www.haomeiwen.com/subject/oeluuftx.html