AgentSkillsCN

xcode-build-performance

分析Xcode编译耗时,识别编译速度较慢的目标以及优化空间。当编译过程缓慢、用户询问“为什么编译这么慢?”或希望优化编译时间时,可使用此技能。

SKILL.md
--- frontmatter
name: xcode-build-performance
description: Analyzes Xcode build timing to identify slow targets and optimization opportunities. Use when build is slow, user asks "why is the build so slow?", or wants to optimize compile times.
allowed-tools: Bash(swift:*), Read, Glob

Xcode Build Performance Analyzer

Identifies slow compilation targets and provides optimization recommendations.

When to Use

  • User complains build is slow
  • User asks "why is my build taking so long?"
  • User wants to optimize build times
  • After running build with -showBuildTimingSummary

Usage

Capturing Build Timing

Run your build with timing summary enabled:

bash
xcodebuild -scheme MyApp -showBuildTimingSummary build 2>&1 | tee build-timing.log

Analyzing Timing

bash
swift ~/.claude/plugins/xcode-dx-skills/skills/xcode-build-performance/scripts/extract-timing.swift build-timing.log

What Gets Analyzed

  • Target compilation times: Which modules take longest to build
  • Type checking time: Swift type inference bottlenecks
  • Incremental build efficiency: Cache hit rates
  • Slowest files: Individual files that take longest to compile

Common Optimization Suggestions

Slow Type Checking

  • Add explicit type annotations
  • Break complex expressions into smaller parts
  • Avoid deeply nested generics

Low Cache Hit Rate

  • Check for volatile build settings
  • Ensure derived data isn't being cleared
  • Look for timestamp-based invalidation

Large Modules

  • Split into smaller targets
  • Use incremental compilation
  • Consider module boundaries

Output Format

The script outputs JSON with:

  • targets: Build times per target
  • slowest_files: Top files by compile time
  • type_check_time: Time spent in Swift type checking
  • cache_stats: Incremental build cache statistics
  • recommendations: Suggested optimizations