38

我正在尝试直接从终端运行发布版本,但我没有找到这样做的选项。

从 XCode 需要做的是:

产品 -> 方案 -> 编辑方案(cmd + <),确保您在侧面的“运行”选项卡中,并将“构建配置”下拉菜单设置为“发布”。

http://facebook.github.io/react-native/docs/running-on-device-ios.html#building-your-app-for-production

有什么选项可以react-native-cli做同样的事情吗?像react-native run-ios -configuration Release什么?

我的目标是生成一个不需要正在运行的服务器来提供给 QA 团队的构建。

4

3 回答 3

111

我对 React Native 项目进行了 PR 以允许此功能。PR 可以在这里查看:https ://github.com/facebook/react-native/commit/ca7cbdee858e84c4a74a2d9c7be151f5cfdcfbfe

因此,将来,要从终端运行发布版本,您只需键入以下命令:npx react-native run-ios --configuration Release

如果你想在真实设备上运行你的项目使用--device参数:

npx react-native run-ios --configuration Release --device "Your Device Name"
于 2016-11-10T18:48:03.117 回答
0

据我所知,React Native 并没有那种开箱即用的东西。

但是因为你的 react-native 应用程序也是一个简单的 Objective-C 应用程序,内部有 react-native,你可以重用现有的工具来为你执行构建/打包。

例如,查看以下文章,了解如何使用fastlane自动化构建。

https://shift.infinite.red/simple-react-native-ios-releases-4c28bb53a97b#.i1otlntat

于 2016-10-28T12:24:09.567 回答
0

处理捆绑的 react-native 脚本在这里:

  ./node_modules/react-native/scripts/react-native-xcode.sh

它基本上是这样做的:

  node "./node_modules/react-native/cli.js" bundle  --entry-file "index.js" --platform ios --dev false --reset-cache --bundle-output "./app.app/main.jsbundle" --assets-dest "./app.app"

其中 bundle-output 和 assets-dest 通常指向您的 xcode 构建输出。例如:

~/Library/Developer/Xcode/DerivedData/MyApp-enjmlvtpwwpnsxanntxwgpneywcy/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphonesimulator/MyApp.app
于 2021-07-08T17:00:57.603 回答