1

问题描述

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

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

屏幕截图 2017 年 10 月 26 日上午 8 点 56 分 29 分

在此处输入图像描述

环境

  • Npm : 5.5.1
  • 反应原生 cli:2.0.1
  • 反应原生:0.45.1
  • React Native Navigation 版本:最新
  • 平台(iOS、Android 或两者?):(MacOS Sierra:10.12.6(16G29,两者)
  • 设备信息(模拟器/设备?操作系统版本?调试/发布?):版本 10.0 (SimulatorApp-829.6 CoreSimulator-494.22.3)/Debug

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...~
4

2 回答 2

1

通常,正如错误所说,反应本机开发人员服务器未运行。默认情况下,它应该使用开发人员服务器打开另一个终端以进行本机反应。有时它可能会挂在那里你可以在另一个终端中重新运行 react-native run-ios 而你有一个终端打开,如果没有尝试 rm -rf ~/.rncache 并删除 ios 构建

于 2017-10-26T03:26:06.140 回答
0

第一步

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

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

  • 冲泡安装节点
  • 酿造安装守望者
  • 酿造链接自动制作pcre
  • npm install -g react-native-cli
  • 导出 ANDROID_HOME=~/Library/Android/sdk
  • 导出 PATH=${PATH}:${ANDROID_HOME}
  • react-native run-android
于 2017-10-26T05:00:38.437 回答