monorepo react-native ios 真机调试

432 阅读1分钟

模拟器调试 需要改成如下

  #if DEBUG
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/mobile/index" fallbackResource:nil];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif

真机调试,跟踪源码后, 再 0.64.1 版本下可以改成如下,

  • 注意必须还要USB连接,才能调试。有点麻烦。还是模拟器调试方便点。
  #if DEBUG
   return [RCTBundleURLProvider jsBundleURLForBundleRoot:@"packages/mobile/index"
                                               packagerHost:@"192.168.1.18:8081"
                                                  enableDev:true
                                         enableMinification:true];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif