【问题标题】:React-Native Remote Debugger not working on iPhoneReact-Native 远程调试器无法在 iPhone 上运行
【发布时间】:2016-11-23 19:38:36
【问题描述】:

我在我的 iPhone 上运行一个 React-Native 应用程序,该应用程序似乎可以正常加载,但是当我摇动并启用远程 JS 调试时,我收到此错误:

我尝试关注 React-Native 的文档 https://facebook.github.io/react-native/docs/running-on-device-ios.html,但它似乎已经过时了。

AppDelegate.m

#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application     didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  [[RCTBundleURLProvider sharedSettings] setDefaults];
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];


  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"abcrn123"
                                           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;
}

@end

任何帮助将不胜感激,我正在尝试在真实设备上运行和调试 React-Native 应用程序。

谢谢,道格。

【问题讨论】:

    标签: ios objective-c xcode reactjs react-native


    【解决方案1】:

    有时会超时。我通常用这个步骤。 1、摇一摇,停止远程调试。 2.让它运行。 3、再次摇一摇,返回远程调试。 4. 应该重新加载。你应该很高兴。

    我知道这很烦人......

    【讨论】:

      【解决方案2】:

      我今天克服了这个困难。这是使用React Native Debugger 的流程:

      1. 清除所有缓存以重新开始:watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean -force && npm install,按照:https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d
      2. $ REACT_DEBUGGER="open -g 'rndebugger://set-debugger-loc?port=8081' ||" react-native start
        (现在打包程序正在运行 - 切换终端窗口)
      3. $ react-native run-ios --device "iPad" (或任何您的设备名称)
      4. 在绿色状态栏中记下 iPad 或加载期间列出的 IP 地址
      5. 从你的设备中甩掉垃圾,然后在弹出窗口中选择“启用远程 JS 调试”
      6. $ open "rndebugger://set-debugger-loc?host=192.168.1.231&port=8081"
        ip address == 绿色状态栏中列出的地址(不是 iPad wifi 设置中的地址)...

      【讨论】:

        【解决方案3】:

        我不再试图让它发挥作用, 只是

        1. npm install -g localtunnel
        2. lt --port 8081
        3. 复制此命令输出的 url,并将其放置到您的 AppDelegate.m 中,如下所示 return [NSURL URLWithString:@"https://blue-termites-13.localtunnel.me/index.bundle?platform=ios&dev=true"];

        【讨论】:

          猜你喜欢
          • 2016-06-28
          • 2019-03-09
          • 2013-07-22
          • 2016-12-04
          • 2019-10-04
          • 1970-01-01
          • 2012-09-11
          • 2020-04-13
          • 1970-01-01
          相关资源
          最近更新 更多