从终端运行 React Native iOS 版本构建
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40303229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run a React Native iOS release build from terminal
提问by Sandro Machado
I am trying to run the release build directly from the terminal and I did not found an option to do that.
我试图直接从终端运行发布版本,但我没有找到这样做的选项。
From XCode what is required to do is:
从 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.
Product -> Scheme -> Edit Scheme (cmd + <),确保你在侧面的 Run 选项卡中,并将 Build Configuration 下拉菜单设置为 release。
There is any option available from the react-native-cli
to do the same? Something like react-native run-ios -configuration Release
?
有任何可用的选项可以react-native-cli
做同样的事情吗?像react-native run-ios -configuration Release
什么?
My objective is to generate a build that does not require the server being running to provide to the QA team for instance.
我的目标是生成一个不需要正在运行的服务器来提供给 QA 团队的构建。
回答by Sandro Machado
I did a PR to the React Native project to allow this feature. The PR can be check here: https://github.com/facebook/react-native/commit/ca7cbdee858e84c4a74a2d9c7be151f5cfdcfbfe
我对 React Native 项目做了 PR 以允许此功能。PR可以在这里查看:https: //github.com/facebook/react-native/commit/ca7cbdee858e84c4a74a2d9c7be151f5cfdcfbfe
So, in the future, to run a release build from terminal you just only need to type the following command: react-native run-ios --configuration Release
因此,将来要从终端运行发布版本,您只需要键入以下命令: react-native run-ios --configuration Release
If you want run your project on a real device use --device
parameter:
如果您想在真实设备上运行您的项目,请使用--device
参数:
react-native run-ios --configuration Release --device "Your Device Name"
回答by Thomas
As far as I know, react native doesn't come with something like that out-of-the-box.
据我所知,react native 并没有像那种开箱即用的东西。
But because your react-native app is also a plain Objective-C app with react-native on the inside, you can re-use existing tools to perform the build/packaging for you.
但是因为你的 react-native 应用程序也是一个普通的 Objective-C 应用程序,内部带有 react-native,你可以重用现有的工具来为你执行构建/打包。
Check the following article for example on how to automate your build using fastlane.
例如,查看以下文章,了解如何使用fastlane自动构建。
https://shift.infinite.red/simple-react-native-ios-releases-4c28bb53a97b#.i1otlntat
https://shift.infinite.red/simple-react-native-ios-releases-4c28bb53a97b#.i1otlntat