formatting-build-output

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

xcsift - Xcode Build Output Formatter

xcsift - Xcode构建输出格式化工具

xcsift is a Swift command-line tool that parses and formats xcodebuild/SPM output for coding agents. It transforms verbose Xcode build output into token-efficient TOON format optimized for machine readability.
xcsift是一款Swift命令行工具,用于为编码Agent解析并格式化xcodebuild/SPM的输出。它将冗长的Xcode构建输出转换为令牌效率优化的TOON格式,更适合机器读取。

When to Use

使用场景

Use xcsift when running Swift or Xcode build commands:
  • xcodebuild build
  • xcodebuild test
  • swift build
  • swift test
在运行Swift或Xcode构建命令时使用xcsift:
  • xcodebuild build
  • xcodebuild test
  • swift build
  • swift test

Usage Pattern

使用模式

Always pipe build output through xcsift with stderr redirected:
bash
undefined
始终通过xcsift管道传输构建输出,并重定向stderr:
bash
undefined

Basic usage

基础用法

xcodebuild build 2>&1 | xcsift -f toon swift build 2>&1 | xcsift -f toon
xcodebuild build 2>&1 | xcsift -f toon swift build 2>&1 | xcsift -f toon

With warnings

显示警告

xcodebuild build 2>&1 | xcsift -f toon -w
xcodebuild build 2>&1 | xcsift -f toon -w

With code coverage

包含代码覆盖率

swift test --enable-code-coverage 2>&1 | xcsift -f toon -c xcodebuild test -enableCodeCoverage YES 2>&1 | xcsift -f toon -c
swift test --enable-code-coverage 2>&1 | xcsift -f toon -c xcodebuild test -enableCodeCoverage YES 2>&1 | xcsift -f toon -c

With executable targets

包含可执行目标

xcodebuild build 2>&1 | xcsift -f toon -e
xcodebuild build 2>&1 | xcsift -f toon -e

Strict CI mode (fail on warnings)

严格CI模式(警告视为错误)

xcodebuild build 2>&1 | xcsift -f toon -W -E
undefined
xcodebuild build 2>&1 | xcsift -f toon -W -E
undefined

Key Flags

关键参数

FlagDescription
-f toon
TOON format (30-60% fewer tokens)
-w
Show detailed warnings
-W
Treat warnings as errors
-q
Quiet mode (no output on success)
-c
Include code coverage
-e
Include executable targets
-E
Exit with failure on build failure
--build-info
Per-target phases and timing
参数说明
-f toon
TOON格式(令牌数量减少30-60%)
-w
显示详细警告
-W
将警告视为错误
-q
静默模式(成功时无输出)
-c
包含代码覆盖率
-e
包含可执行目标
-E
构建失败时以失败状态退出
--build-info
按目标显示阶段和耗时

Output Format

输出格式

TOON format provides structured output optimized for LLMs:
toon
status: failed
summary:
  errors: 1
  warnings: 3
errors[1]{file,line,message}:
  main.swift,15,"use of undeclared identifier"
warnings[3]{file,line,message}:
  Parser.swift,20,"unused variable"
TOON格式提供针对LLM优化的结构化输出:
toon
status: failed
summary:
  errors: 1
  warnings: 3
errors[1]{file,line,message}:
  main.swift,15,"use of undeclared identifier"
warnings[3]{file,line,message}:
  Parser.swift,20,"unused variable"

Important

重要提示

  • Always use
    2>&1
    to capture stderr (where compiler errors are written)
  • TOON format reduces tokens by 30-60% compared to raw xcodebuild output
  • The hook automatically wraps build commands when installed
  • 始终使用
    2>&1
    捕获stderr(编译器错误会输出到这里)
  • 与原始xcodebuild输出相比,TOON格式可减少30-60%的令牌数量
  • 安装后,钩子会自动包装构建命令