$npx -y skills add avdlee/xcode-build-optimization-agent-skill --skill xcode-build-fixerApply approved Xcode build optimization changes following best practices, then re-benchmark to verify improvement. Use when a developer has an approved optimization plan from xcode-build-orchestrator, wants to apply specific build fixes, needs help implementing build setting chan
| 1 | # Xcode Build Fixer |
| 2 | |
| 3 | Use this skill to implement approved build optimization changes and verify them with a benchmark. |
| 4 | |
| 5 | ## Core Rules |
| 6 | |
| 7 | - Only apply changes that have explicit developer approval. |
| 8 | - Apply one logical fix at a time so changes are reviewable and reversible. |
| 9 | - Re-benchmark after applying changes to verify improvement. |
| 10 | - Report exactly what changed, which files were touched, and the measured delta. |
| 11 | - If a change produces no improvement or causes a regression, flag it immediately. |
| 12 | |
| 13 | ## Inputs |
| 14 | |
| 15 | The fixer expects one of: |
| 16 | |
| 17 | - An approved optimization plan at `.build-benchmark/optimization-plan.md` with checked approval boxes. |
| 18 | - An explicit developer instruction describing the fix to apply (e.g., "set `DEBUG_INFORMATION_FORMAT` to `dwarf` for Debug"). |
| 19 | |
| 20 | When working from an optimization plan, read the approval checklist and implement only the checked items. |
| 21 | |
| 22 | ## Fix Categories |
| 23 | |
| 24 | ### Build Settings |
| 25 | |
| 26 | Change `project.pbxproj` values to match the recommendations in [build-settings-best-practices.md](references/build-settings-best-practices.md). |
| 27 | |
| 28 | Typical fixes: |
| 29 | |
| 30 | - Set `DEBUG_INFORMATION_FORMAT = dwarf` for Debug |
| 31 | - Set `SWIFT_COMPILATION_MODE = singlefile` for Debug |
| 32 | - Enable `COMPILATION_CACHE_ENABLE_CACHING = YES` |
| 33 | - Enable `EAGER_LINKING = YES` for Debug |
| 34 | - Align cross-target settings to eliminate module variants |
| 35 | |
| 36 | When editing `project.pbxproj`, locate the correct `buildSettings` block by matching the target name and configuration name. Verify the change with `xcodebuild -showBuildSettings` after applying. |
| 37 | |
| 38 | ### Script Phases |
| 39 | |
| 40 | Fix run script phases that waste time during incremental or debug builds. |
| 41 | |
| 42 | Typical fixes: |
| 43 | |
| 44 | - Add input and output file declarations so Xcode can skip unchanged scripts. |
| 45 | - Add configuration guards: `[[ "$CONFIGURATION" != "Release" ]] && exit 0` for release-only scripts. |
| 46 | - Move input/output lists into `.xcfilelist` files when the list is long. |
| 47 | - Enable `Based on dependency analysis` when inputs and outputs are declared. |
| 48 | |
| 49 | ### Source-Level Compilation Fixes |
| 50 | |
| 51 | Apply code changes that reduce type-checker and compiler overhead. See [references/fix-patterns.md](references/fix-patterns.md) for before/after patterns. |
| 52 | |
| 53 | Typical fixes: |
| 54 | |
| 55 | - Add explicit type annotations to complex expressions. |
| 56 | - Break long chained or nested expressions into intermediate typed variables. |
| 57 | - Mark classes `final` when they are not subclassed. |
| 58 | - Tighten access control (`private`/`fileprivate`) for internal-only symbols. |
| 59 | - Extract monolithic SwiftUI `body` properties into smaller composed subviews. |
| 60 | - Replace deeply nested result-builder code with separate typed helpers. |
| 61 | - Add explicit return types to closures passed to generic functions. |
| 62 | |
| 63 | ### SPM Restructuring |
| 64 | |
| 65 | Restructure Swift packages to improve build parallelism and reduce rebuild scope. |
| 66 | |
| 67 | Typical fixes: |
| 68 | |
| 69 | - Move shared types to a lower-layer module to eliminate circular or upward dependencies. |
| 70 | - Split oversized modules (200+ files) by feature area. |
| 71 | - Extract protocol definitions into lightweight interface modules. |
| 72 | - Remove unnecessary `@_exported import` usage. |
| 73 | - Align build options across targets that import the same packages to prevent module variant duplication. |
| 74 | - Pin branch-tracked dependencies to tagged versions or commit hashes for deterministic resolution. |
| 75 | |
| 76 | Before applying version pin changes: |
| 77 | |
| 78 | - Run `git ls-remote --tags <url>` to confirm tags exist. If the upstream has no tags, pin to a specific revision hash instead. |
| 79 | - Verify the pinned version resolves successfully with `xcodebuild -resolvePackageDependencies` before proceeding. |
| 80 | |
| 81 | ## Execution Workflow |
| 82 | |
| 83 | 1. Read the approved optimization plan or developer instruction. |
| 84 | 2. For each approved item, identify the exact files and locations to change. |
| 85 | 3. Apply the change. |
| 86 | 4. Verify the change compiles: run a quick `xcodebuild build` to confirm no errors were introduced. |
| 87 | 5. After all approved changes are applied, re-benchmark using the same inputs from the original baseline: |
| 88 | ```bash |
| 89 | python3 scripts/benchmark_builds.py \ |
| 90 | --project App.xcodeproj \ |
| 91 | --scheme MyApp \ |
| 92 | --configuration Debug \ |
| 93 | --destination "platform=iOS Simulator,name=iPhone 16" \ |
| 94 | --output-dir .build-benchmark |
| 95 | ``` |
| 96 | 6. Compare post-change medians to the baseline and report deltas. |
| 97 | |
| 98 | ## Evaluating Regressions |
| 99 | |
| 100 | Not every slower number is a true regression. The fixer must evaluate the full picture before recommending a revert. |
| 101 | |
| 102 | ### Compilation caching trade-off |
| 103 | |
| 104 | A change like `COMPILATION_CACHE_ENABLE_CACHING = YES` may make a standard clean build slightly slower (cache population overhead) while m |