---
title: "让 Claude 直接读取 xcodebuild 编译错误的 Claude Code 外挂"
url: "https://claudemods.dev/zh-cn/builds/i-built-a-claude-code-mod-that-gives-claude-your-xcodebuild--d9a001"
source: "https://github.com/griches/xcpane"
source_type: "github"
repo: "https://github.com/griches/xcpane"
author: "Gary_BBGames"
author_handle: "Gary_BBGames"
stars: 4
category: "开发与调试"
categories: ["debug", "tools", "workflow"]
tags: ["bash-tool", "claude-code-mod", "error-summary", "swift", "xcodebuild", "xcresulttool"]
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add griches/xcpane\nclaude plugin install xcpane@griches"
added: "2026-10-04T00:04:24.843Z"
updated: "2026-10-09T14:27:09Z"
locale: "zh-cn"
content_locale: "zh-cn"
---

# 让 Claude 直接读取 xcodebuild 编译错误的 Claude Code 外挂

作者利用新的 mod 系统制作了一个外挂：Claude 通过 Bash 运行 xcodebuild 失败时，它会自动追加 -resultBundlePath，再用 xcresulttool 提取错误、警告和测试失败，让 Claude 看到

## Description

这是一个面向使用 xcodebuild 配合 Claude 的 Claude Code 外挂。问题在于，Bash 命令失败且输出很长时，Claude Code 只会把开头和结尾交给模型，中间部分会被截断；而失败的 xcodebuild 恰好会把编译错误放在中间。作者举了一个例子：一个小型 Swift package 有 3 个编译错误，日志长达 295 行，Claude 只收到 10,039 个字符，完全没有拿到错误信息；它知道哪些文件失败了，却不知道原因，只能 grep 源码，再用自己的过滤条件重新运行。

这个 mod 的做法是：给 xcodebuild 命令追加 -resultBundlePath，然后使用 xcresulttool 从 Xcode 的结果包中读取错误、警告和测试失败；把 Claude 读取的内容替换成摘要。在同一项测试中，摘要只有 499 个字符，却包含每个报告错误的文件、行号和列号；转录记录仍然保留原始输出；它还会按文件显示错误、失败的测试、警告和最近构建的分组面板。

局限是：在作者的测试中，它没有让 Claude 用更少的构建次数修复项目（两种方式都是 3 次），但修复过程更高效，因为不再需要寻找错误。它只能看到 Claude 通过 Bash 运行的构建，脚本、make 或 fastlane 内部的构建看不到；swift build 只能从日志中读取。源码、安装说明和一个短 GIF 位于 GitHub 仓库中。

## Install

```
claude plugin marketplace add griches/xcpane
claude plugin install xcpane@griches
```

## Original README

I built a mod for Claude Code with the new mod system. It's for anyone who lets Claude run xcodebuild. When a Bash command fails with long output, Claude Code gives the model the start and the end and cuts out the middle. A failing xcodebuild puts the compiler errors in the middle. On a small Swift package with three compile errors, the log was 295 lines and Claude received 10,039 characters, none of them an error message. It knew which files failed but not why, so it grepped the source and re-ran the build through its own filter. It: - Appends `-resultBundlePath` to the xcodebuild command and reads errors, warnings and test failures from Xcode's result bundle with xcresulttool. - Replaces what Claude reads with a summary: in the same test, 499 characters with every reported error's file, line and column. The transcript keeps the raw output. - Shows a pane with errors grouped by file, failed tests, warnings and recent builds. It doesn't: It didn't make Claude fix the project in fewer builds in my test (three either way) but it does make it fix the issues more efficiently as it doesn't need to search the errors. It only sees builds Claude runs through Bash, not builds inside scripts, make or fastlane. swift build is read from the log only. Source, install instructions and a short GIF: https://github.com/griches/claude-xcode-mod (MIT) Happy to answer questions about the mod API, since there isn't much written about it yet. submitted by /u/Gary_BBGames [link] [comments]
