xcode-cloud

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Xcode Cloud

Xcode Cloud

Overview

概述

Provide a repeatable setup for Xcode Cloud custom scripts, with ready-to-copy templates for XcodeGen generation and post-archive Git tagging.
提供Xcode Cloud自定义脚本的可重复设置方案,附带可直接复制的XcodeGen生成及归档后Git标签推送模板。

Quick Start

快速开始

  1. Identify the folder that contains the
    .xcodeproj
    or
    .xcworkspace
    .
  2. Check whether the
    .xcodeproj
    /
    .xcworkspace
    is tracked in git. If it is generated and ignored, you must use
    ci_post_clone.sh
    (or commit the generated project).
  3. Create
    ci_scripts/
    in that folder if missing.
  4. Copy templates from
    assets/
    .
  5. Customize variables noted in the templates.
  6. chmod +x ci_scripts/*.sh
    .
  7. In Xcode Cloud, add required secrets (for tagging) and ensure an Archive action exists.
  1. 找到包含
    .xcodeproj
    .xcworkspace
    的文件夹。
  2. 检查
    .xcodeproj
    /
    .xcworkspace
    是否已被git追踪。如果它是生成的且被忽略,则必须使用
    ci_post_clone.sh
    (或提交生成的项目)。
  3. 如果缺少
    ci_scripts/
    文件夹,在该目录下创建它。
  4. assets/
    中复制模板文件。
  5. 自定义模板中标记的变量。
  6. 执行
    chmod +x ci_scripts/*.sh
  7. 在Xcode Cloud中添加所需的密钥(用于标签推送),并确保存在Archive操作。

Workflow: XcodeGen + Tagging

工作流:XcodeGen + 标签推送

1) Place scripts where Xcode Cloud expects them

1) 将脚本放置在Xcode Cloud期望的位置

Create
ci_scripts/
at the same level as the
.xcodeproj
/
.xcworkspace
. Xcode Cloud only recognizes the three official filenames; use
ci_pre_xcodebuild.sh
(or
ci_post_clone.sh
) for XcodeGen and
ci_post_xcodebuild.sh
for tagging.
在与
.xcodeproj
/
.xcworkspace
同级的目录下创建
ci_scripts/
。Xcode Cloud仅识别三个官方文件名;使用
ci_pre_xcodebuild.sh
(或
ci_post_clone.sh
)来处理XcodeGen,使用
ci_post_xcodebuild.sh
来处理标签推送。

2) XcodeGen project generation

2) XcodeGen项目生成

Use
ci_post_clone.sh
if your
.xcodeproj
/
.xcworkspace
is generated and not committed. Xcode Cloud validates the project path and schemes before
ci_pre_xcodebuild.sh
runs, so pre-xcodebuild is too late in that setup. Copy
assets/ci_post_clone.sh
to
ci_scripts/ci_post_clone.sh
. Use
ci_pre_xcodebuild.sh
only when the project already exists in the repo. Adjust the root detection if your
project.yml
is not at repo root.
如果你的
.xcodeproj
/
.xcworkspace
是生成的且未提交,请使用
ci_post_clone.sh
。 Xcode Cloud会在
ci_pre_xcodebuild.sh
运行前验证项目路径和scheme,因此在这种设置下,pre-xcodebuild的时机太晚。 将
assets/ci_post_clone.sh
复制到
ci_scripts/ci_post_clone.sh
。 仅当项目已存在于仓库中时,才使用
ci_pre_xcodebuild.sh
。 如果你的
project.yml
不在仓库根目录,请调整根目录检测逻辑。

3) Tagging after successful archives

3) 成功归档后推送标签

Copy
assets/ci_post_xcodebuild.sh
to
ci_scripts/ci_post_xcodebuild.sh
. Set
INFO_PLIST_PATH
(or provide it as an Xcode Cloud env var). Set
TAG_PREFIX
if you want a custom prefix. Ensure the workflow includes an Archive action; otherwise the script will no-op. Add
GITHUB_TOKEN
as a secret environment variable in Xcode Cloud.
assets/ci_post_xcodebuild.sh
复制到
ci_scripts/ci_post_xcodebuild.sh
。 设置
INFO_PLIST_PATH
(或通过Xcode Cloud环境变量提供)。 如果需要自定义前缀,请设置
TAG_PREFIX
。 确保工作流包含Archive操作;否则脚本将不执行任何操作。 在Xcode Cloud中添加
GITHUB_TOKEN
作为保密环境变量。

4) Make scripts executable

4) 使脚本可执行

Run
chmod +x ci_scripts/*.sh
after adding or editing scripts.
添加或编辑脚本后,执行
chmod +x ci_scripts/*.sh

Template Assets

模板资源

  • assets/ci_pre_xcodebuild.sh
    : XcodeGen install + project generation (two-script setup)
  • assets/ci_post_clone.sh
    : XcodeGen install + project generation (alternative)
  • assets/ci_post_xcodebuild.sh
    : archive-only tag push using
    GITHUB_TOKEN
  • assets/ci_pre_xcodebuild.sh
    :XcodeGen安装 + 项目生成(双脚本设置)
  • assets/ci_post_clone.sh
    :XcodeGen安装 + 项目生成(替代方案)
  • assets/ci_post_xcodebuild.sh
    :使用
    GITHUB_TOKEN
    仅在归档后推送标签

Notes

注意事项

  • Use the
    apple-docs-research
    skill when you need official Apple documentation on Xcode Cloud behavior or environment variables.
  • Keep logs free of secrets; use Xcode Cloud secret environment variables for tokens.
  • Reference
    references/xcode-cloud-notes.md
    for quick reminders about doc lookups.
  • If you see
    Project <Name>.xcodeproj does not exist at <path>
    , Xcode Cloud validated the project before your script ran. Fix by switching to
    ci_post_clone.sh
    or committing the generated project.
  • 当你需要关于Xcode Cloud行为或环境变量的官方Apple文档时,请使用
    apple-docs-research
    技能。
  • 日志中不要包含敏感信息;使用Xcode Cloud保密环境变量来存储令牌。
  • 参考
    references/xcode-cloud-notes.md
    获取文档查询的快速提示。
  • 如果看到
    Project <Name>.xcodeproj does not exist at <path>
    错误,说明Xcode Cloud在你的脚本运行前就验证了项目。请切换到
    ci_post_clone.sh
    或提交生成的项目来修复该问题。