ios - 在一个命令中运行 react-native run-ios 和 react-native start?

标签 ios react-native

我刚刚从 RN 59 升级到 RN 60.2 并且 react-native run-ios 用于启动 Metro Bundler 然后打开模拟器并运行应用程序,现在不再这样做了。它们现在需要是单独的命令。

我不确定如何将 react-native startreact-native run-ios 作为一个命令运行,因为 start 确实不会自行终止,因此不会告诉 run-ios 运行。

这是我目前拥有的脚本:

"scripts": {
    "ios": "react-native run-ios --simulator=\"iPhone 11\"",
    "rename": "node ./bin/rename.js",
    "start": "react-native start",
}

我的想法是这样的:

react-native start && react-native run-ios

到目前为止,最好的替代方法是向后运行它们并让它构建应用程序,然后启动 Metro Bundler:

react-native run-ios && react-native start

这会导致模拟器首先启动并显示 bundler 未在线的错误消息,然后运行服务器,然后让我重新加载模拟器。这不太理想。

是否有替代方法?

最佳答案

好吧,试试这个方法

"custom":"react-native run-android && react-native start"

然后,一旦您进入 package.json 所在的项目根目录,系统就会指示您在终端中运行“npm run custom”。

关于ios - 在一个命令中运行 react-native run-ios 和 react-native start?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58406684/

相关文章:

ios - Swift 窗口 View 顶部的 subview

ios - UITextField 占位符具有不同的字体大小

javascript - 如何在 React-Native 中加载 .wasm 文件?

ios - 初始化自定义 UICollectionViewCell

ios - 如何从 iOS 的共享扩展中的扩展上下文中获取项目?

firebase - 使用 redux 在 react-native 应用程序中保存访问 token 的最佳做法是什么?

typescript :onPress 类型

javascript - 如何在 react native 组件中延迟运行异步等待?

ios - React Native 更改默认 iOS 模拟器设备

ios - Xcode 12.0.1 屏幕截图仅在 iOS 模拟器上捕获主屏幕