为本机应用程序创建暂存环境

Create staging environment for react native app

我正在尝试按照 this post 为我的 React Native 应用程序设置暂存环境。 post 要求将调用 Staging 的新配置添加到 Xcode 项目并使用它来构建项目。我添加了 Staging 配置,它是 Release 配置的副本,但我无法使用该配置构建应用程序。我收到以下错误:

React/RCTBridgeModule.h file not found

我在 DebugRelease 配置中没有收到此错误。我读到 react-native 为配置名称 DebugRelease 分配了特殊含义,但我不确定如何解决这个问题。我还查看了 react-native-config 以设置暂存环境,但初始设置对我来说有点复杂,而且我当时不明白。而其他 post 中列出的步骤非常容易理解,基本上是创建一个单独的配置并使用用于 运行 应用程序的配置来确定应用程序所在的环境 运行宁在。

如果您已经能够使用这种方法或其他方法为您的 react-native 应用程序创建暂存环境,请分享。

谢谢!

我觉得你应该看看这个posthttps://github.com/Microsoft/react-native-code-push#ios

我的方法是:

  1. 安装代码推送

首先,安装CodePush CLI:

npm install -g code-push-cli

然后转到 React Native 项目的根目录并使用命令行:

npm install --save react-native-code-push

然后 link 图书馆:

react-native link react-native-code-push

之后,我们需要用我们的账号登录code-push(你可以在这里找到Mobile Center账号):

code-push login

您还可以使用以下命令检查您是否已经登录:

code-push whoami
  1. 创建部署密钥

在我们部署任何更新之前,我们需要使用以下命令向 CodePush 服务注册一个应用程序:

code-push app add <appName> <os> <platform>

例如:

code-push app add myapp-ios ios react-native

code-push app add my-android android react-native

之后您应该会在 Mobile Center 中看到刚刚添加的内容 https://mobile.azure.com/apps 下一步是通过键入命令行检查部署密钥:

code-push deployment ls <appName> -k

例如:

code-push deployment ls myapp-ios -k

code-push deployment ls myapp-android -k
  1. Link 部署密钥

要发布更新,我们需要 link React Native 项目的部署密钥。 https://github.com/Microsoft/react-native-code-push#ios

  1. 发布更新

最终设置部署密钥后,最后一步是上传第一个更新。 将index.ios.jsindex.android.js文件改成:

import codePush from "react-native-code-push";
let codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESUME,
};

class MyApp extends Component {
...
}

export default MyApp = codePush(codePushOptions)(MyApp);

现在输入命令行:

code-push release-react <appName> <platform>

例如

code-push release-react myapp-ios ios

code-push release-react myapp-android android

完成此步骤后,您将看到第一个版本正在上传到 Mobile Center

剩下的就变得很容易了。任何时候我们想要进行更新,我们只需要在命令行中输入 code-push release-react code-push 就会进行静默更新。

将暂存推送到生产也只是一个命令作业:

code-push promote <APP_NAME> Staging Production -r 100%