前提条件
继续教程之前,请确保…
- 确保您使用 GitHub
- 使用 Capacitor
- 您的应用程序已经在 Apple Store 上部署
- 想读😆…
使用 Ionic 是可选的,Cordova 可能会工作,但我没有尝试
关于价格的重要信息

https://developer.apple.com/xcode-cloud/
该服务是 ‘免费' 达到上限。
您可以在截图中看到价格和限制(截图创建时的价格,可能会在未来发生变化)
🔴 一旦警告了需求和价格,如果您喜欢,我们继续…
📣 在文章中,我们假设我们已经在 Apple Store 中创建了应用
简介
要让 Xcode 构建您的 Capacitor 应用程序,您需要设置一些东西。
包准备
确保您的构建命令在您的脚本中。 package.json 然后添加命令如下。 sync:ios 这个步骤将使后脚本工作简单
{
"scripts": {
"build": "YOUR BUILD COMMAND",
"sync:ios": "cap sync ios"
}
}
克隆后脚本
post clone script
This script will be run by Xcode cloud after the clone step
#!/usr/bin/env bash
set -x
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
# Install CocoaPods
echo "📦 Install CocoaPods"
brew install cocoapods
brew install node@18
brew link node@18
# Install dependencies
# XCode Cloud is literally broken for 2 months now - https://developer.apple.com/forums/thread/738136?answerId=774510022#774510022
npm config set maxsockets 3
npm ci
# or `pnpm install --frozen-lockfile` or `yarn add --frozen-lockfile` or bun install
npm run build
# or npm run build
npm run sync:ios
将这个文件保存在你的项目根目录并命名为 ios/App/ci_scripts/ci_post_clone.sh
然后用这个命令使这个文件可执行 chmod +x ios/App/ci_scripts/ci_post_clone.sh
创建 Xcode 工作流
打开 Xcode(是的,为了移除 Xcode 你需要 Xcode)
然后去这个选项卡:

点击创建工作流,选择你的应用,点击下一步像下面一样

点击左侧的编辑工作流

去到环境选项卡,选择像下面一样 Mac 12.4 并勾选合适的选项

选择您的启动条件。 如果您使用与我们相同的构建,我建议使用标签而不是分支,以避免双重构建.
设置您的环境变量

连接您的 GitHub 账户


然后启用工作流并提交您的第一个更改,您应该在 Xcode 中看到您的构建正在运行.
构建处理中
在 Xcode Cloud 中, 您根据运行 CI/CD 工作流的分钟数而被billing。从经验来看,构建在 Apple Store 中处理需要约 10–15 分钟。 In Xcode Cloud, you are billed based on the minutes you have used for running your CI/CD workflow. From experience, it takes about 10–15 minutes before a build can be processed in the Apple Store.
For private projects, the estimated cost per build can go up to $0.008/min x 5 mins = $0.4, or more, depending on the configuration or dependencies of your project.
For Open-source projects, this shouldn’t be a problem at all. See https://capgo.com/pricing.
Keep going from How to build Ionic Capacitor app in Xcode Cloud
If you are using How to build Ionic Capacitor app in Xcode Cloud to plan CI/CD automation, connect it with Capgo CI/CD for the product workflow in Capgo CI/CD, Capgo Native Builds 为产品工作流程中的Capgo原生构建 Capgo集成 为产品工作流程中的Capgo集成 CI/CD集成 为CI/CD集成的实现细节,和 GitHub动作集成 为GitHub动作集成的实现细节。