gpt4 book ai didi

ios - 如何运行 React-Native 示例?

转载 作者:技术小花猫 更新时间:2023-10-29 10:19:41 24 4
gpt4 key购买 nike

我找不到任何关于如何安装和运行“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”),然后在 Xcode 中打开“/react-native/Examples/Movies/Movies.xcodeproj”,然后运行项目,它似乎构建良好。模拟器出现,显示应用程序的“电影”介绍屏幕,但随后出现红色死亡屏幕并打印出:

: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 运行 Movie Project。

如果你想“隔离” MovieProject 或另一个 react-native 示例项目,简单的方法是初始化一个新的 react native 应用程序(react-native init MyAppName)并复制 JS示例项目(在电影项目下方的示例中)中的文件放入新的应用程序文件夹中。

然后不要忘记编辑您的 iOS/AppDelegate.m 文件。

你必须编辑 2 行:

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];

关于ios - 如何运行 React-Native 示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29327219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com