AgentSkillsCN

xcode-build-errors

分析Xcode编译失败的原因,解释错误信息并提出修复建议。当编译失败、出现编译器错误、链接器错误、代码签名失败,或用户询问“为什么编译会失败?”“这个错误是什么意思?”时,可使用此技能。

SKILL.md
--- frontmatter
name: xcode-build-errors
description: Analyzes Xcode build failures to explain errors and suggest fixes. Use when build fails, compiler errors appear, linker errors occur, code signing fails, or user asks "why did the build fail?" or "what does this error mean?"
allowed-tools: Bash(swift:*), Read, Glob

Xcode Build Error Analyzer

Parses and explains Xcode build failures, providing actionable guidance for fixing errors.

When to Use

  • User pastes build output containing errors
  • User asks "why did my build fail?"
  • User asks "what does this error mean?"
  • Build log contains compilation, linking, or signing errors
  • User shares .xcresult bundle path

Usage

From Build Output

If the user pastes build output directly, first filter it to extract errors:

bash
echo "<pasted-output>" | swift ~/.claude/plugins/xcode-dx-skills/skills/xcode-log-filter/scripts/filter-log.swift

From Log File

bash
swift ~/.claude/plugins/xcode-dx-skills/skills/xcode-build-errors/scripts/parse-build-errors.swift /path/to/build.log

From xcresult Bundle

bash
swift ~/.claude/plugins/xcode-dx-skills/skills/xcode-build-errors/scripts/parse-build-errors.swift /path/to/Build.xcresult

Error Categories

The script categorizes errors to help with diagnosis:

CategoryExamples
compilerType mismatches, missing imports, syntax errors
linkerUndefined symbols, duplicate symbols, library not found
signingProvisioning profile issues, certificate problems
resourceMissing assets, storyboard errors, Info.plist issues
swift_typeComplex type inference failures, protocol conformance
dependencySPM resolution failures, framework embedding

Analysis Approach

  1. Parse errors using the script to get structured data
  2. Group by category to identify patterns (e.g., "all linker errors")
  3. Identify root cause - often the first error causes subsequent ones
  4. Explain the error in plain terms
  5. Suggest specific fixes with code examples when applicable

Common Error Patterns

Type Mismatch

code
Cannot convert value of type 'X' to expected argument type 'Y'
  • Check if types are compatible
  • Look for missing type conversions or casts
  • Consider if an optional needs unwrapping

Undefined Symbol

code
Undefined symbol: _OBJC_CLASS_$_SomeClass
  • Framework not linked - add to "Link Binary With Libraries"
  • Missing -ObjC linker flag for static libraries
  • SPM target not properly declared as dependency

Signing Issues

code
No signing certificate "iOS Development" found
  • Certificate not installed in Keychain
  • Provisioning profile expired or missing
  • Bundle identifier mismatch

Module Not Found

code
No such module 'SomeFramework'
  • SPM dependency not resolved - run swift package resolve
  • Framework search paths incorrect
  • Build order issue - dependency not built first

Output Format

The script outputs JSON with:

  • errors: Array of errors with file, line, message, category
  • error_groups: Errors grouped by category
  • root_cause_candidates: Most likely root cause errors
  • fix_suggestions: Suggested fixes based on error patterns