axiom-xcode-mcp-tools by charleswiltgen/axiom
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-xcode-mcp-tools核心原则:Xcode MCP 为您提供编程式的 IDE 访问。使用工作流循环,而非孤立的工具调用。
大多数工具都需要一个 tabIdentifier。务必先调用 XcodeListWindows。
1. XcodeListWindows → 获取 (tabIdentifier, workspacePath) 对列表
2. 将 workspacePath 与您的项目匹配
3. 在后续所有工具调用中使用该 tabIdentifier
缓存此映射关系以供当前会话使用。仅在以下情况时重新获取:
如果 XcodeListWindows 返回空列表:Xcode 没有打开任何项目。请用户打开他们的项目。
迭代地进行构建、诊断和修复,直到项目编译成功。
1. BuildProject(tabIdentifier)
2. 检查 buildResult — 如果成功,则完成
3. GetBuildLog(tabIdentifier) → 解析错误
4. XcodeListNavigatorIssues(tabIdentifier) → 获取规范诊断信息
5. 对每个诊断使用 XcodeUpdate(file, fix) 进行修复
6. 回到步骤 1(最多 5 次迭代)
7. 如果同一错误在 3 次尝试后仍然存在 → 回退到 axiom-xcode-debugging
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
为何优先使用 XcodeListNavigatorIssues 而非解析构建日志:问题导航器提供结构化、去重后的诊断信息。构建日志包含原始的编译器输出,带有干扰信息。
何时回退到 axiom-xcode-debugging:当错误是环境问题(僵尸进程、过期的 Derived Data、模拟器问题)而非代码级别问题时。MCP 工具操作代码;环境问题需要 CLI 诊断。
对失败的测试进行快速迭代。
1. GetTestList(tabIdentifier) → 发现可用测试
2. RunSomeTests(tabIdentifier, [specific failing tests]) 进行快速迭代
3. 解析失败信息 → 识别需要修复的代码
4. 使用 XcodeUpdate(file, fix) 修补代码
5. 回到步骤 2(每个测试最多 5 次迭代)
6. 使用 RunAllTests(tabIdentifier) 作为最终验证
为何先使用 RunSomeTests:运行单个测试只需几秒钟。运行所有测试需要几分钟。先对失败的测试进行迭代,待其通过后再验证整个测试套件。
解析测试结果:查看响应中的 testResult 字段。失败的测试包含带有文件路径和行号的失败消息。
渲染 SwiftUI 预览并直观地验证 UI 更改。
1. RenderPreview(tabIdentifier, sourceFilePath, previewDefinitionIndexInFile: 0) → 图像产物
2. 检查渲染的图像是否正确
3. 如果进行更改:使用 XcodeUpdate → 再次 RenderPreview
4. 比较更改前后的图像以检查回归问题
使用场景:验证布局更改、检查深色模式外观、确认 Liquid Glass 效果是否正确渲染。
使用 Xcode 的问题导航器作为规范诊断信息来源。
1. XcodeListNavigatorIssues(tabIdentifier) → 获取所有当前问题
2. 对于特定文件:XcodeRefreshCodeIssuesInFile(tabIdentifier, file)
3. 优先级排序:错误 > 警告 > 备注
4. 先修复错误,重新构建,再次检查
为何优先使用此方法而非 grep-for-errors:问题导航器跟踪实时诊断,包括类型检查错误、缺失的导入以及只有 Xcode 编译器前端才会暴露的约束问题。
通过 MCP 查询 Apple 的文档库。
1. DocumentationSearch(query) → 获取文档结果
2. 与 axiom-apple-docs 交叉引用,获取捆绑在 Xcode 中的指南
注意:DocumentationSearch 搜索 Apple 的在线文档和 WWDC 文稿。对于捆绑在 Xcode 内部的 20 个面向 LLM 的指南,请使用 axiom-apple-docs。
| 操作 | 工具 | 备注 |
|---|---|---|
| 读取文件内容 | XcodeRead | 查看 Xcode 的项目视图(生成的文件、已解析的包) |
| 创建新文件 | XcodeWrite | 创建文件 — 自动添加到项目结构中 |
| 编辑现有文件 | XcodeUpdate | str_replace 风格的补丁 — 比完全重写更安全 |
| 搜索文件 | XcodeGlob | 在项目内进行模式匹配 |
| 搜索文件内容 | XcodeGrep | 带行号的内容搜索 |
| 列出目录 | XcodeLS | 目录列表 |
| 创建目录 | XcodeMakeDir | 创建目录 |
| 操作 | 工具 | 风险 |
|---|---|---|
| 删除文件/目录 | XcodeRM | 默认移动到废纸篓 (deleteFiles: true) — 需与用户确认 |
| 移动/重命名文件 | XcodeMV | 可能会破坏导入和引用 |
在调用 XcodeRM 或 XcodeMV 之前,务必与用户确认破坏性操作。
| 场景 | 使用 MCP | 使用标准工具 (Read/Write/Grep) |
|---|---|---|
| Xcode 项目视图中的文件 | 是 — 包括生成/已解析的文件 | 可能会遗漏生成的文件 |
| 项目外的文件 | 否 | 是 — 标准工具随处可用 |
| 需要构建上下文(编辑后的诊断) | 是 — 在一个工作流中编辑 + 重新构建 | 无构建集成 |
| 简单的文件读取/编辑 | 两者皆可 | 稍快(无 MCP 开销) |
ExecuteSnippet(tabIdentifier, codeSnippet: "print(MyModel.self)", sourceFilePath: "Sources/MyModel.swift")
在特定 Swift 文件的上下文中运行代码 — 可以访问该文件的 fileprivate 声明。不是通用的 REPL。没有 language 参数(仅限 Swift)。
在以下情况下,标签标识符会失效:
修复方法:重新调用 XcodeListWindows 以获取新的标识符。
XcodeWrite — 创建一个新文件。如果文件已存在,则失败(在某些客户端中)。XcodeUpdate — 使用 oldString/newString 替换来修补现有文件。每次调用进行一次替换(使用 replaceAll: true 替换所有出现)。常见错误:使用 XcodeWrite 编辑现有文件会覆盖其全部内容。请使用 XcodeUpdate 进行编辑。
Xcode 的 mcpbridge 存在一个已知的 MCP 规范违规:当工具声明 outputSchema 时,它会填充 content 但省略 structuredContent。这会破坏严格的 MCP 客户端(Cursor,某些 Zed 配置)。
变通方法:对于严格的客户端,使用 XcodeMCPWrapper 作为代理。
在 XcodeUpdate 之后,项目可能需要重新构建才能显示新的诊断信息。不要假设编辑是正确的而不重新构建。
| 想法 | 现实 |
|---|---|
| "我直接用 xcodebuild" | MCP 提供了 CLI 没有的 IDE 状态 + 导航器诊断 + 预览 |
| "Read 工具对 Xcode 文件没问题" | XcodeRead 能看到 Xcode 的项目视图,包括生成的文件和已解析的包 |
| "跳过标签标识符,我只有一个项目" | 大多数工具在没有 tabIdentifier 时会静默失败 — 务必先调用 XcodeListWindows |
| "每次都运行所有测试" | 使用 RunSomeTests 进行迭代,RunAllTests 进行验证 — 每个周期节省几分钟 |
| "我解析构建日志找错误" | XcodeListNavigatorIssues 提供结构化、去重后的诊断信息 |
| "用 XcodeWrite 更新文件" | 编辑用 XcodeUpdate。XcodeWrite 用于创建/覆盖。用错工具 = 数据丢失。 |
| "一次工具调用就够了" | 工作流(BuildFix, TestFix)使用循环。孤立的调用会错过迭代模式。 |
技能:axiom-xcode-mcp-setup, axiom-xcode-mcp-ref, axiom-xcode-debugging
每周安装数
90
仓库
GitHub 星标数
687
首次出现
2026年2月16日
安全审计
安装于
opencode87
gemini-cli86
codex86
amp85
kimi-cli85
github-copilot85
Core principle : Xcode MCP gives you programmatic IDE access. Use workflow loops, not isolated tool calls.
Most tools require a tabIdentifier. Always callXcodeListWindows first.
1. XcodeListWindows → list of (tabIdentifier, workspacePath) pairs
2. Match workspacePath to your project
3. Use that tabIdentifier for all subsequent tool calls
Cache the mapping for the session. Only re-fetch if:
IfXcodeListWindows returns empty: Xcode has no project open. Ask the user to open their project.
Iteratively build, diagnose, and fix until the project compiles.
1. BuildProject(tabIdentifier)
2. Check buildResult — if success, done
3. GetBuildLog(tabIdentifier) → parse errors
4. XcodeListNavigatorIssues(tabIdentifier) → canonical diagnostics
5. XcodeUpdate(file, fix) for each diagnostic
6. Go to step 1 (max 5 iterations)
7. If same error persists after 3 attempts → fall back to axiom-xcode-debugging
WhyXcodeListNavigatorIssues over build log parsing: The Issue Navigator provides structured, deduplicated diagnostics. Build logs contain raw compiler output with noise.
When to fall back toaxiom-xcode-debugging: When the error is environmental (zombie processes, stale Derived Data, simulator issues) rather than code-level. MCP tools operate on code; environment issues need CLI diagnostics.
Fast iteration on failing tests.
1. GetTestList(tabIdentifier) → discover available tests
2. RunSomeTests(tabIdentifier, [specific failing tests]) for fast iteration
3. Parse failures → identify code to fix
4. XcodeUpdate(file, fix) to patch code
5. Go to step 2 (max 5 iterations per test)
6. RunAllTests(tabIdentifier) as final verification
WhyRunSomeTests first: Running a single test takes seconds. Running all tests takes minutes. Iterate on the failing test, then verify the full suite once it passes.
Parsing test results : Look for testResult field in the response. Failed tests include failure messages with file paths and line numbers.
Render SwiftUI previews and verify UI changes visually.
1. RenderPreview(tabIdentifier, sourceFilePath, previewDefinitionIndexInFile: 0) → image artifact
2. Review the rendered image for correctness
3. If making changes: XcodeUpdate → RenderPreview again
4. Compare before/after for regressions
Use cases : Verifying layout changes, checking dark mode appearance, confirming Liquid Glass effects render correctly.
Use Xcode's Issue Navigator as the canonical diagnostics source.
1. XcodeListNavigatorIssues(tabIdentifier) → all current issues
2. For specific files: XcodeRefreshCodeIssuesInFile(tabIdentifier, file)
3. Prioritize: errors > warnings > notes
4. Fix errors first, rebuild, re-check
Why this over grep-for-errors : The Issue Navigator tracks live diagnostics including type-check errors, missing imports, and constraint issues that only Xcode's compiler frontend surfaces.
Query Apple's documentation corpus through MCP.
1. DocumentationSearch(query) → documentation results
2. Cross-reference with axiom-apple-docs for bundled Xcode guides
Note : DocumentationSearch searches Apple's online documentation and WWDC transcripts. For the 20 for-LLM guides bundled inside Xcode, use axiom-apple-docs instead.
| Operation | Tool | Notes |
|---|---|---|
| Read file contents | XcodeRead | Sees Xcode's project view (generated files, resolved packages) |
| Create new file | XcodeWrite | Creates file — auto-adds to project structure |
| Edit existing file | XcodeUpdate | str_replace-style patches — safer than full rewrites |
| Search for files | XcodeGlob | Pattern matching within the project |
| Search file contents | XcodeGrep |
| Operation | Tool | Risk |
|---|---|---|
| Delete file/directory | XcodeRM | Moves to Trash by default (deleteFiles: true) — confirm with user |
| Move/rename file | XcodeMV | May break imports and references |
Always confirm destructive operations with the user before calling XcodeRM or XcodeMV.
| Scenario | Use MCP | Use Standard (Read/Write/Grep) |
|---|---|---|
| Files in the Xcode project view | Yes — includes generated/resolved files | May miss generated files |
| Files outside the project | No | Yes — standard tools work everywhere |
| Need build context (diagnostics after edit) | Yes — edit + rebuild in one workflow | No build integration |
| Simple file read/edit | Either works | Slightly faster (no MCP overhead) |
ExecuteSnippet(tabIdentifier, codeSnippet: "print(MyModel.self)", sourceFilePath: "Sources/MyModel.swift")
Runs code in the context of a specific Swift file — has access to that file's fileprivate declarations. Not a generic REPL. No language parameter (Swift only).
Tab identifiers become invalid when:
Fix : Re-call XcodeListWindows to get fresh identifiers.
XcodeWrite — creates a new file. Fails if file exists (in some clients).XcodeUpdate — patches an existing file with oldString/newString replacement. One replacement per call (use replaceAll: true for all occurrences).Common mistake : Using XcodeWrite to edit an existing file overwrites its entire contents. Use XcodeUpdate for edits.
Xcode's mcpbridge has a known MCP spec violation: it populates content but omits structuredContent when tools declare outputSchema. This breaks strict MCP clients (Cursor, some Zed configurations).
Workaround : Use XcodeMCPWrapper as a proxy for strict clients.
After XcodeUpdate, the project may need a build to surface new diagnostics. Don't assume edits are correct without rebuilding.
| Thought | Reality |
|---|---|
| "I'll just use xcodebuild" | MCP gives IDE state + navigator diagnostics + previews that CLI doesn't |
| "Read tool works fine for Xcode files" | XcodeRead sees Xcode's project view including generated files and resolved packages |
| "Skip tab identifier, I only have one project" | Most tools fail silently without tabIdentifier — always call XcodeListWindows first |
| "Run all tests every time" | RunSomeTests for iteration, RunAllTests for verification — saves minutes per cycle |
| "I'll parse the build log for errors" | XcodeListNavigatorIssues provides structured, deduplicated diagnostics |
Skills : axiom-xcode-mcp-setup, axiom-xcode-mcp-ref, axiom-xcode-debugging
Weekly Installs
90
Repository
GitHub Stars
687
First Seen
Feb 16, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode87
gemini-cli86
codex86
amp85
kimi-cli85
github-copilot85
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
45,200 周安装
| Content search with line numbers |
| List directory | XcodeLS | Directory listing |
| Create directory | XcodeMakeDir | Creates directories |
| "XcodeWrite to update a file" | XcodeUpdate for edits. XcodeWrite creates/overwrites. Wrong tool = data loss. |
| "One tool call is enough" | Workflows (BuildFix, TestFix) use loops. Isolated calls miss the iteration pattern. |