mac 上的 react-native-navigation 无法连接到开发服务器

Cound not connect to development server in react-native-navigation on mac

问题描述

我克隆了 React-native-navigation 并在使用 npm install 命令后定向到 运行 应用程序的示例。

克隆 URL : https://github.com/wix/react-native-navigation

屏幕截图 2017-10-26 8 56 29 am

环境

AppDelegate.m:

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>

// **********************************************
// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
// **********************************************
#import "RCCManager.h"

// IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
// with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)

#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;
#ifdef DEBUG
  //jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
   jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif


  // **********************************************
  // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
  // **********************************************
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];
  //self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  /*
  // original RN bootstrap - remove this part
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"example"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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

错误日志

Loading dependency graph...2017-10-26 11:15 node[1963] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-10-26 11:15 node[1963] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-10-26 11:15 node[1963] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
 ERROR  Error watching file for changes: EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"Error watching file for changes:","filename":null}
Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1018:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1420:11)
Loading dependency graph...~

正常情况下,错误提示 React Native 开发者服务器未 运行ning。默认情况下,它应该打开另一个带有开发人员服务器的终端以进行本机反应。有时它会挂在那里,你可以在另一个终端中重新 运行 react-native 运行-ios ,而你已经打开了,如果那不尝试 rm -rf ~ /.rcache 并删除 ios build

第一步

  • 酿造更新
  • brew 安装守望者

如果第一步失败尝试第二步

  • brew 安装节点
  • brew 安装守望者
  • brew link automake pcre
  • npm install -g react-native-cli
  • 出口ANDROID_HOME=~/Library/Android/sdk
  • 导出路径=${路径}:${ANDROID_HOME}
  • react-native 运行-android