我找不到关于如何安装和运行"https://github.com/facebook/react-native/tree/master/Examples"中提供的其他示例之一(如"https://github.com/facebook/react-native/tree/master/Examples/Movies")的任何说明.

本教程只告诉你要做什么

react-native init AwesomeProject

它代表着"https://github.com/facebook/react-native/tree/master/Examples/SampleApp".


如果我克隆整个"react native"存储库,然后运行

npm install
npm start

从根文件夹(即"/react native"),然后打开"/react native/Examples/Movies/Movies".xcodeproj’在Xcode中运行该项目,它似乎构建得很好.模拟器出现,显示应用程序的"电影"介绍屏幕,但随后死亡的红色屏幕出现,打印出:

:0

终端在根文件夹中运行"npm start",打印出:

Error: EISDIR, read
    at Error (native)
[02:35:02] <START> request:/Examples/Movies/MoviesApp.includeRequire.runModule.bundle

推荐答案

只需遵循Getting Started Tutorial就可以了,只需在react-native 目录中运行npm install即可.

然后用Xcode运行电影项目.

如果你想"隔离"MovieProject或另一个react-native 示例项目,简单的方法是初始化一个新的react-native 应用程序(react-native init MyAppName),然后将JS文件从示例项目(在电影项目下面的示例中)复制到新的应用程序文件夹中.

然后别忘了编辑iOS/AppDelegate.m文件.

您必须编辑两行:

jsCodeLocation = [NSURL URLWithString:@"http:/localhost:8081/index.ios.bundle"];

作者:

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/MoviesApp.bundle"];

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                  moduleName:@"MyAppName"
                                               launchOptions:launchOptions];

作者:

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                  moduleName:@"MoviesApp"
                                               launchOptions:launchOptions];

React-native相关问答推荐

在第二次加载时仅将本机应用程序设置为状态

React Native - React Native 架构

FBSDK 和 LinkingManager 的 AppDelegate.m

Javascript setTimeout 立即在 React Native 中运行

找不到变量 atob

React Native 用于低互联网带宽的小型 apk APP应用

React Native 在升级到 0.56 版本后崩溃

react-native 链接仅适用于一个项目(Android 或 iOS)

带有 react-navigation 的 DrawerNavigation 标头

Property body[41] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"

React Native + Jest EMFILE:too many open files error

React Native Negative shadowOffset 创建顶部阴影

如何在 React Native 上获取设备的 ip?

使用 expo SDK react-native ios 应用程序的 Info.plist 文件

[React-Native][Jest]SyntaxError: Unexpected token import

React Native Android 负边距(Margins)

带有 React Native 的 EventEmitter 和 Subscriber ES6 语法

React-native Awesome 元素没有构建 android 元素

react-navigation 标题有一条微弱的线

如何在 react-native 中为带有图标的按钮建模