catalog/repos/abdullah4ai--apple-developer-toolkit.md

377 lines
14 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 苹果开发者工具套件
`iOS开发` `SwiftUI` `App Store` `CLI工具` `代码生成`
<div align="center">
<br>
# Apple Developer Toolkit
**三合一工具单一二进制文件。文档、App Store 和应用构建器**
搜索 Apple 文档、管理 App Store Connect并通过自然语言构建多平台应用
<br>
[![Node.js](https://img.shields.io/badge/Node.js-18+-339933?style=flat&logo=node.js&logoColor=white)](https://nodejs.org)
[![Swift](https://img.shields.io/badge/Swift-6-FA7343?style=flat&logo=swift&logoColor=white)](https://swift.org)
[![macOS](https://img.shields.io/badge/macOS-only-000000?style=flat&logo=apple&logoColor=white)](https://developer.apple.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat)](LICENSE)
</div>
<br>
```
$ appledev build
> 一个带连续打卡计数和每周网格视图的习惯追踪应用
✓ 已分析StreakGrid
✓ 计划就绪11 个文件3 个模型)
✓ 构建完成 — 11 个文件
✓ 已在 iPhone 17 Pro 上启动
```
以单一统一二进制文件 `appledev` 发布,内含三个独立工具。每个工具可单独使用,凭证要求各不相同。
## 安装
```bash
brew install Abdullah4AI/tap/appledev
```
<details>
<summary>从源码安装</summary>
```bash
git clone https://github.com/Abdullah4AI/apple-developer-toolkit.git
cd apple-developer-toolkit
bash scripts/setup.sh
```
</details>
## Agent 技能
为任意 AI 编程 Agent 添加 iOS 和 SwiftUI 知识——支持 Claude Code、Codex、Cursor、Windsurf、Gemini CLI 等:
```bash
# 安装全部技能(推荐)
npx add-skill Abdullah4AI/apple-developer-toolkit
# 安装指定技能
npx add-skill Abdullah4AI/apple-developer-toolkit --skill ios-rules
npx add-skill Abdullah4AI/apple-developer-toolkit --skill swiftui-guides
```
| 技能 | 新增内容 | Token 消耗 |
|---|---|---|
| `ios-rules` | 38 条 iOS 规范无障碍、导航、架构、深色模式、本地化、App 审核 | ~20K tokens |
| `swiftui-guides` | 12 篇 SwiftUI 指南:液态玻璃、状态管理、动画、布局、性能 | ~20K tokens |
技能开箱即用,兼容所有支持 [Agent Skills](https://agentskills.io) 格式的 Agent。
## 包含内容
<table>
<tr>
<td align="center" width="33%">
<br>
<b>文档</b><br>
<sub>Apple 文档 + 1,267 场 WWDC 专题2014-2025</sub><br><br>
<code>node cli.js search</code>
</td>
<td align="center" width="33%">
<br>
<b>App Store Connect</b><br>
<sub>120+ 条命令覆盖构建、TestFlight、提交审核</sub><br><br>
<code>appledev store</code>
</td>
<td align="center" width="33%">
<br>
<b>应用构建器</b><br>
<sub>自然语言转编译好的 SwiftUI 应用</sub><br><br>
<code>appledev build</code>
</td>
</tr>
</table>
| 功能 | 凭证要求 | 无需配置即可使用 |
|---|---|---|
| 文档搜索 | 无 | 是 |
| App Store Connect | API 密钥(.p8 | 否 |
| 应用构建器 | LLM API 密钥 + Xcode | 否 |
## 支持平台
在提示词中提及任意 Apple 平台——可自由组合多个:
<table>
<tr>
<td align="center"><img src="https://img.shields.io/badge/-iPhone-000?style=for-the-badge&logo=apple&logoColor=white" alt="iPhone"><br><sub>默认</sub></td>
<td align="center"><img src="https://img.shields.io/badge/-iPad-000?style=for-the-badge&logo=apple&logoColor=white" alt="iPad"><br><sub>"iPad"</sub></td>
<td align="center"><img src="https://img.shields.io/badge/-Apple%20Watch-000?style=for-the-badge&logo=apple&logoColor=white" alt="Apple Watch"><br><sub>"Apple Watch"</sub></td>
<td align="center"><img src="https://img.shields.io/badge/-Mac-000?style=for-the-badge&logo=apple&logoColor=white" alt="Mac"><br><sub>"Mac"</sub></td>
<td align="center"><img src="https://img.shields.io/badge/-Apple%20TV-000?style=for-the-badge&logo=apple&logoColor=white" alt="Apple TV"><br><sub>"Apple TV"</sub></td>
<td align="center"><img src="https://img.shields.io/badge/-Vision%20Pro-000?style=for-the-badge&logo=apple&logoColor=white" alt="Vision Pro"><br><sub>"Vision Pro"</sub></td>
</tr>
</table>
## 框架
应用尽可能优先使用 Apple 原生框架:
<table>
<tr>
<td align="center"><a href="https://developer.apple.com/xcode/swiftui/"><img src="https://developer.apple.com/assets/elements/icons/swiftui/swiftui-96x96_2x.png" width="36"><br><b>SwiftUI</b></a><br><sub>UI</sub></td>
<td align="center"><a href="https://developer.apple.com/xcode/swiftdata/"><img src="https://developer.apple.com/assets/elements/icons/swiftdata/swiftdata-96x96_2x.png" width="36"><br><b>SwiftData</b></a><br><sub>持久化</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/charts"><img src="https://developer.apple.com/assets/elements/icons/swift-charts/swift-charts-96x96_2x.png" width="36"><br><b>Swift Charts</b></a><br><sub>数据可视化</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/mapkit"><img src="https://developer.apple.com/assets/elements/icons/mapkit/mapkit-96x96_2x.png" width="36"><br><b>MapKit</b></a><br><sub>地图</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/healthkit"><img src="https://developer.apple.com/assets/elements/icons/healthkit/healthkit-96x96_2x.png" width="36"><br><b>HealthKit</b></a><br><sub>健康</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/widgetkit"><img src="https://developer.apple.com/assets/elements/icons/widgetkit/widgetkit-96x96_2x.png" width="36"><br><b>WidgetKit</b></a><br><sub>小组件</sub></td>
</tr>
<tr>
<td align="center"><a href="https://developer.apple.com/documentation/avfoundation"><img src="https://developer.apple.com/assets/elements/icons/avfoundation/avfoundation-96x96_2x.png" width="36"><br><b>AVFoundation</b></a><br><sub>相机与媒体</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/photokit"><img src="https://developer.apple.com/assets/elements/icons/photokit/photokit-96x96_2x.png" width="36"><br><b>PhotosUI</b></a><br><sub>照片选取器</sub></td>
<td align="center"><a href="https://developer.apple.com/documentation/activitykit"><img src="https://developer.apple.com/assets/elements/icons/activitykit/activitykit-96x96_2x.png" width="36"><br><b>ActivityKit</b></a><br><sub>实时活动</sub></td>
<td align="center"><a href="https://developer.apple.com/machine-learning/core-ml/"><img src="https://developer.apple.com/assets/elements/icons/core-ml/core-ml-96x96_2x.png" width="36"><br><b>CoreML</b></a><br><sub>机器学习</sub></td>
<td align="center"><a href="https://developer.apple.com/augmented-reality/arkit/"><img src="https://developer.apple.com/assets/elements/icons/arkit/arkit-96x96_2x.png" width="36"><br><b>ARKit</b></a><br><sub>增强现实</sub></td>
<td align="center"><a href="https://developer.apple.com/augmented-reality/realitykit/"><img src="https://developer.apple.com/assets/elements/icons/realitykit/realitykit-96x96_2x.png" width="36"><br><b>RealityKit</b></a><br><sub>3D 与空间计算</sub></td>
</tr>
</table>
## 发布
无需离开终端,直接发布到 App Store 和 TestFlight。
<table>
<tr>
<td align="center"><img src="https://cdn.simpleicons.org/appstore/0D96F6" width="40" alt="App Store"><br><b>App Store</b><br><sub>完整提交流程</sub></td>
<td align="center"><img src="https://developer.apple.com/assets/elements/icons/testflight/testflight-96x96_2x.png" width="40" alt="TestFlight"><br><b>TestFlight</b><br><sub>Beta 版本分发</sub></td>
</tr>
</table>
## 集成
在提示词中提及身份验证、数据库或付费功能,工具包会自动接入支持的后端服务。
<table>
<tr>
<td align="center"><a href="https://www.revenuecat.com"><img src="https://cdn.simpleicons.org/revenuecat/F25A5A" width="40"><br><b>RevenueCat</b></a><br><sub>订阅与付费墙</sub></td>
<td align="center"><a href="https://supabase.com"><img src="https://cdn.simpleicons.org/supabase/3FCF8E" width="40"><br><b>Supabase</b></a><br><sub>身份验证、数据库、存储</sub></td>
<td align="center"><img src="https://cdn.simpleicons.org/telegram/26A5E4" width="40"><br><b>Telegram</b><br><sub>构建与审核通知</sub></td>
<td align="center"><img src="https://upload.wikimedia.org/wikipedia/commons/d/d5/Slack_icon_2019.svg" width="40" alt="Slack"><br><b>Slack</b><br><sub>团队通知</sub></td>
<td align="center"><img src="assets/feishu-icon.svg" width="40" alt="Feishu"><br><b>飞书 / Lark</b><br><sub>团队通知</sub></td>
<td align="center"><img src="https://cdn.simpleicons.org/git/F05032" width="40"><br><b>Git</b><br><sub>自动打版本标签</sub></td>
</tr>
</table>
## 文档搜索
在本地搜索 Apple 框架、符号和 WWDC 专题,无需 API 密钥。
```bash
node cli.js search "NavigationStack" # 框架搜索
node cli.js symbols "UIView" # 符号查询
node cli.js doc "/documentation/swiftui/view" # 完整文档
node cli.js overview "SwiftUI" # 框架概览
node cli.js samples "SwiftUI" # 示例代码
```
```bash
node cli.js wwdc-search "concurrency" # 搜索 WWDC 演讲
node cli.js wwdc-year 2025 # 按年份浏览
node cli.js wwdc-topic "swiftui-ui-frameworks" # 按主题浏览
```
## App Store Connect
120+ 条命令,全面覆盖 App Store Connect API。
```bash
# 身份验证
appledev store auth login --name "MyApp" \
--key-id "KEY_ID" --issuer-id "ISSUER_ID" \
--private-key ./AuthKey.p8
# 发布到 TestFlight
appledev store publish testflight \
--app "APP_ID" --ipa app.ipa --group "Beta" --wait
# 提交到 App Store
appledev store publish appstore \
--app "APP_ID" --ipa app.ipa --submit --confirm --wait
# 提交前验证
appledev store validate --app "APP_ID" --version-id "VER_ID"
```
<details>
<summary>所有命令分类</summary>
| 分类 | 命令 |
|---|---|
| **入门** | auth、doctor、init、docs |
| **应用** | apps、app-setup、versions、localizations、screenshots、video-previews |
| **TestFlight** | testflight、builds、sandbox、feedback、crashes |
| **审核与发布** | review、reviews、submit、validate、publish、status |
| **签名** | signing、bundle-ids、certificates、profiles、notarization |
| **变现** | iap、subscriptions、offer-codes、win-back-offers、pricing |
| **数据分析** | analytics、insights、finance、performance |
| **自动化** | xcode-cloud、webhooks、workflow、metadata、diff、migrate |
</details>
## 应用构建器
通过自然语言构建完整的多平台 Apple 应用。
```
> 一个带食材清单、分步操作说明和计时器的菜谱应用
✓ 已分析RecipeBook
✓ 计划就绪16 个文件4 个模型)
✓ 构建完成 — 16 个文件
✓ RecipeBook 已就绪!
```
### 工作原理
```
描述 → 分析 → 规划 → 构建 → 修复 → 运行
↑ │ │ │ │ │
提示词 应用名 文件 Swift xcode- iOS
功能 模型 代码 build 模拟器
```
| 阶段 | 发生了什么 |
|---|---|
| **分析** | 从描述中提取应用名称、功能和核心流程 |
| **规划** | 生成包含模型、导航和依赖包的文件级构建计划 |
| **构建** | 生成 Swift 源码、资源目录和 Xcode 项目 |
| **修复** | 使用 `xcodebuild` 编译并自动修复,直到通过 |
| **运行** | 启动模拟器并运行应用 |
### 命令
| 命令 | 说明 |
|---|---|
| `appledev build` | 交互模式 |
| `appledev build chat` | 编辑现有项目 |
| `appledev build fix` | 自动修复编译错误 |
| `appledev build run` | 构建并在模拟器中启动 |
| `appledev build open` | 在 Xcode 中打开 |
| `appledev build setup` | 安装前置依赖 |
<details>
<summary>交互命令</summary>
| 命令 | 说明 |
|---|---|
| `/run` | 构建并在模拟器中启动 |
| `/fix` | 自动修复编译错误 |
| `/ask <问题>` | 查询项目信息(只读) |
| `/open` | 在 Xcode 中打开 |
| `/model <名称>` | 切换 AI 模型 |
| `/info` | 显示项目信息 |
| `/usage` | Token 用量与费用 |
</details>
## 生命周期钩子
跨 4 个分类共 42 个事件。可通过 Telegram 接收通知、自动分发到 TestFlight、为发布打 Git 标签,并将操作串联成流水线。
```bash
# 使用模板初始化钩子
bash scripts/hook-init.sh --template indie
# 手动触发钩子
bash scripts/hook-runner.sh build.done STATUS=success APP_NAME=MyApp
# 演练运行
bash scripts/hook-runner.sh --dry-run build.done STATUS=success
```
### 模板
| 模板 | 适用场景 |
|---|---|
| `indie` | 独立开发者 — Telegram 通知、自动发布到 TestFlight |
| `team` | 团队 — Slack + Telegram、Git 标签、变更日志 |
| `ci` | CI/CD — 日志记录、运行测试、无交互通知 |
| `feishu` | 飞书/Lark — 面向中国开发团队的 Webhook 通知 |
### 内置脚本
| 脚本 | 用途 |
|---|---|
| `notify-telegram.sh` | 发送 Telegram 通知 |
| `notify-feishu.sh` | 发送飞书/Lark 通知 |
| `git-tag-release.sh` | 创建并推送 Git 标签 |
| `run-swift-tests.sh` | 运行 Swift 测试 |
| `generate-changelog.sh` | 从 Git 历史生成变更日志 |
<details>
<summary>配置示例</summary>
```yaml
version: 1
notifiers:
telegram:
enabled: true
bot_token_keychain: "my-bot-token"
chat_id: "123456"
feishu:
enabled: true
webhook_url_env: "FEISHU_WEBHOOK_URL"
hooks:
build.done:
- name: notify-build
notify: telegram
template: "{{if eq .STATUS \"success\"}}✅{{else}}❌{{end}} {{.APP_NAME}} 构建"
- name: notify-build-feishu
notify: feishu
template: "{{if eq .STATUS \"success\"}}✅{{else}}❌{{end}} {{.APP_NAME}} 构建"
store.review.approved:
- name: tag-release
run: "git tag v{{.VERSION}} && git push origin v{{.VERSION}}"
```
配置文件位置:
- **全局:** `~/.appledev/hooks.yaml`
- **项目:** `.appledev/hooks.yaml`
</details>
## AI Agent 参考资料
52 个参考文件,助力 AI 辅助开发:
| 参考资料 | 数量 | 内容 |
|---|---|---|
| `references/ios-rules/` | 38 | iOS 开发规范(无障碍、深色模式、本地化等) |
| `references/swiftui-guides/` | 12 | SwiftUI 最佳实践(液态玻璃、导航、状态管理等) |
| `references/app-store-connect.md` | 1 | 完整 CLI 参考手册 |
| `references/hooks-reference.md` | 1 | 所有钩子事件及上下文变量 |
## 环境要求
| 功能 | 依赖 |
|---|---|
| 文档搜索 | Node.js 18+ |
| App Store Connect | API 密钥(.p8 文件) |
| 应用构建器 | Xcode + LLM API 密钥 |
| 生命周期钩子 | 无 |
## 许可证
MIT
<div align="center">
<sub><a href="https://abdullah4.ai">Abdullah AlRashoudi</a> 构建</sub>
</div>