如何在 React Native 中获得 iOS 的离线捆绑?

How to get offline bundling of iOS in React Native?

谁能解释一下如何从 'react native' 代码生成 iOS 应用程序的离线包?

我已经试过了但是还是不行。

react-native run-ios --configuration=release

将 运行 您的应用程序在模拟器或设备上使用捆绑包。

或者直接从 Xcode 构建它(发布版本总是包含包) 或 运行 调试版本,但在此之前,您应该:

react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios

此外,找不到新的 react-native 版本 index.ios.js 因为我们需要 运行 这个,

react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios

方法一

第一步:

react-native bundle --entry-file index.ios.js --bundle-output ./ios/main.jsbundle --platform ios

第二步:

react-native run-ios --configuration=release 

这个工人是我的。

方法二 使用 xcode 并将 debug 更改为 release,如下所示:

我假设您希望在 ios 设备上 运行 该应用程序而不将其部署到应用程序商店。 如果是这样的话:

首先我要确保我已经安装了 ios-deploy

您可以通过 运行宁 npm install -g ios-deploy

然后将您想要安装该应用程序的 iphone 连接到您的 mac。

然后运行

react-native run-ios --device "XYZ’s iPhone" --configuration=release

这将创建一个离线 js 捆绑应用程序并将其安装到 iphone。

PS:如果出错说

Signing for "<app name>" requires a development team. 
Select a development team in the project editor.

然后在Xcode中打开ios/里面的项目, Select 目标 -> 常规选项卡 在签名下选择签名团队并选择自动管理签名。

然后保存并重新运行命令。