运行 来自终端的 React Native iOS 发布版本

Run a React Native iOS release build from terminal

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

来自XCode需要做的是:

Product -> Scheme -> Edit Scheme (cmd + <), make sure you're in the Run tab from the side, and set the Build Configuration dropdown to release.

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?

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

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

但是因为你的 react-native 应用也是一个普通的 Objective-C 应用,里面有 react-native,你可以重新使用现有的工具来为你执行 build/packaging。

查看以下文章,了解如何使用 fastlane.

自动构建您的示例

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

我对 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"

处理捆绑的 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 和 asset-dest 通常会指向您的 xcode 构建输出。例如:

~/Library/Developer/Xcode/DerivedData/MyApp-enjmlvtpwwpnsxanntxwgpneywcy/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphonesimulator/MyApp.app