codemagic-codepush

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codemagic CodePush Setup

Codemagic CodePush 配置指南

Set up and maintain OTA update delivery for React Native apps through Codemagic-hosted CodePush (
https://codepush.pro
) across iOS and Android.
通过Codemagic托管的CodePush(
https://codepush.pro
)为iOS和Android端的React Native应用搭建并维护OTA更新交付能力。

Expected Output

预期输出

Produce an implementation plan and then concrete edits/commands that include:
  1. Native and JS integration steps for each requested platform.
  2. Copy-paste snippets for exact files (
    Info.plist
    ,
    strings.xml
    ,
    AppDelegate
    ,
    MainApplication.kt
    ,
    codemagic.yaml
    ).
  3. CodePush app/deployment commands and how to retrieve deployment keys.
  4. A release, verification, and rollback path.
先输出落地方案,再提供具体的修改内容/命令,包含:
  1. 各个请求支持平台的原生端和JS端集成步骤
  2. 对应文件(
    Info.plist
    strings.xml
    AppDelegate
    MainApplication.kt
    codemagic.yaml
    )的可直接复制粘贴的代码片段
  3. CodePush应用/部署相关命令,以及获取部署密钥的方法
  4. 发布、验证和回滚流程

Workflow

工作流

  1. Confirm scope and prerequisites.
  2. Configure React Native client integration (JS + native).
  3. Configure Codemagic CI and CodePush CLI auth.
  4. Create platform apps/deployments and wire deployment keys.
  5. Release to
    Staging
    , verify, then promote to
    Production
    .
  6. Troubleshoot or rollback if verification fails.
  1. 确认实施范围和前置条件
  2. 配置React Native客户端集成(JS + 原生端)
  3. 配置Codemagic CI和CodePush CLI鉴权
  4. 创建各平台应用/部署环境,配置对应部署密钥
  5. 发布到
    Staging
    (预发环境)验证通过后,升级到
    Production
    (生产环境)
  6. 如果验证失败,进行问题排查或回滚

Step 1: Confirm Scope And Prerequisites

步骤1:确认实施范围和前置条件

Do the following first:
  1. Confirm the project is React Native (pure Expo managed workflow is not supported by the plugin setup).
  2. Confirm Codemagic has provisioned a CodePush access token for the team.
  3. Confirm whether the user wants setup for both platforms or only one.
  4. Use separate CodePush app names per platform (for example
    MyApp-iOS
    ,
    MyApp-Android
    ).
If prerequisites are missing, stop and list what is needed.
首先完成以下确认:
  1. 确认项目是React Native项目(纯Expo托管工作流不支持该插件配置)
  2. 确认Codemagic已经为团队分配了CodePush访问令牌
  3. 确认用户需要双平台配置还是仅单个平台
  4. 不同平台使用独立的CodePush应用名称(例如
    MyApp-iOS
    MyApp-Android
如果不满足前置条件,停止操作并列出所需的缺失条件。

Step 2: Configure React Native Client Integration

步骤2:配置React Native客户端集成

  1. Install plugin dependency:
    • yarn add @code-push-next/react-native-code-push
  2. Wrap the app root component:
    • import codePush from "@code-push-next/react-native-code-push";
    • export default codePush(App);
  3. Apply platform-native wiring:
    • iOS details: references/setup-ios.md
    • Android details: references/setup-android.md
Always set both server URL and deployment key in native config:
  1. iOS
    Info.plist
    keys:
    CodePushServerURL
    ,
    CodePushDeploymentKey
  2. Android
    strings.xml
    keys:
    CodePushServerUrl
    ,
    CodePushDeploymentKey
  1. 安装插件依赖:
    • yarn add @code-push-next/react-native-code-push
  2. 包裹应用根组件:
    • import codePush from "@code-push-next/react-native-code-push";
    • export default codePush(App);
  3. 完成对应平台的原生端接入:
    • iOS详细说明:references/setup-ios.md
    • Android详细说明:references/setup-android.md
务必在原生配置中同时设置服务端URL和部署密钥:
  1. iOS
    Info.plist
    配置项:
    CodePushServerURL
    CodePushDeploymentKey
  2. Android
    strings.xml
    配置项:
    CodePushServerUrl
    CodePushDeploymentKey

Step 3: Configure Codemagic CI + CLI

步骤3:配置Codemagic CI + CLI

Follow references/codepush-releases-codemagic-ci.md and references/codepush-cli.md to ensure:
  1. @codemagic/code-push-cli
    is installed in workflow scripts.
  2. Login uses Codemagic server URL and token from environment variables.
  3. Release commands target explicit platform app names and deployment channels.
Use https://github.com/codemagic-ci-cd/code-push-pro for CLI reference and ensure all commands align with the current CLI behavior, calling out any discrepancies from project docs.
参考 references/codepush-releases-codemagic-ci.mdreferences/codepush-cli.md 确保满足以下要求:
  1. 工作流脚本中已安装
    @codemagic/code-push-cli
  2. 登录使用环境变量中存储的Codemagic服务端URL和令牌
  3. 发布命令指定明确的平台应用名称和部署渠道
可参考 https://github.com/codemagic-ci-cd/code-push-pro 获取CLI使用说明,确保所有命令符合当前CLI的实际行为,若与项目文档存在差异需明确指出。

Step 4: Verify End-To-End

步骤4:端到端验证

Follow references/verification-and-troubleshooting.md:
  1. Release to
    Staging
    first.
  2. Validate update delivery and metrics.
  3. Promote from
    Staging
    to
    Production
    only after validation.
参考 references/verification-and-troubleshooting.md
  1. 首先发布到
    Staging
    (预发环境)
  2. 验证更新交付能力和相关指标
  3. 仅在验证通过后从
    Staging
    (预发环境)升级到
    Production
    (生产环境)

Execution Rules

执行规则

  1. Prefer exact file edits and commands over abstract guidance.
  2. Keep platform differences explicit; never merge iOS and Android deployment keys.
  3. Use long-form CLI flags when ambiguity exists (for example
    --targetBinaryVersion
    ).
  4. If a command in project docs differs from CLI docs, call out the difference and choose the current CLI behavior.
  1. 优先提供明确的文件修改内容和命令,而非抽象指导
  2. 明确标注平台差异,绝对不要混用iOS和Android的部署密钥
  3. 存在歧义时使用CLI完整参数(例如
    --targetBinaryVersion
  4. 如果项目文档中的命令与CLI官方文档不一致,需指出差异并采用当前CLI的实际行为。