spm-build-analysis
avdlee/xcode-build-optimization-agent-skill
Diagnose Swift Package Manager dependencies, plugins, and build overhead slowing Xcode builds.
What is spm-build-analysis?
Analyzes SPM package structure, dependency graphs, plugins, and module variants to identify build performance bottlenecks. Use when developers report slow clean or incremental builds, package resolution delays, plugin overhead, circular dependencies, or modularization concerns.
- Inspect Package.swift, Package.resolved, and local vs remote package configuration
- Identify dependency graph issues, circular dependencies, and repeated imports
- Analyze package plugin and build-tool overhead during development and CI
- Detect configuration drift causing duplicate module builds across platforms
- Flag oversized modules, umbrella imports, and missing interface/implementation separation
- Assess Swift macro rebuild cascading and multi-platform build multiplication effects
How to install spm-build-analysis
npx skills add https://github.com/avdlee/xcode-build-optimization-agent-skill --skill spm-build-analysis- Xcode project with Package.swift and Package.resolved files
- Access to project.pbxproj for dependency verification
- Optional: build logs or timing summaries showing package-related work
How to use spm-build-analysis
- 1.Examine Package.swift and Package.resolved to map dependency structure
- 2.Verify local packages are actually linked in project.pbxproj using XCLocalSwiftPackageReference and XCSwiftPackageProductDependency
- 3.Run the helper script to check branch-pinned dependencies: python3 scripts/check_spm_pins.py --project App.xcodeproj
- 4.Analyze package graph shape, plugin usage, and module variants for build impact
- 5.Check for circular dependencies, oversized modules, and umbrella imports
- 6.Assess Swift macro usage and multi-platform build multiplication effects
- 7.Document findings with evidence, affected packages, and clean vs incremental build impact
- 8.Recommend changes only with explicit approval; hand off non-package issues to xcode-project-analyzer or xcode-compilation-analyzer
Use cases
- Diagnose why clean builds are slow after adding new SPM dependencies
- Investigate incremental build slowdowns from package plugin usage
- Analyze CI build time increases when adding watchOS or secondary platform targets
- Identify circular dependencies between local packages blocking parallelism
- Evaluate whether modular SDK migrations will improve build performance
- iOS/macOS developers optimizing Xcode build times
- Build engineers analyzing CI pipeline performance
- Teams managing large Swift Package Manager dependency graphs
- Developers refactoring monolithic packages into modular architectures
spm-build-analysis FAQ
No. Treat package analysis as evidence gathering first. Verify the package is actually in your dependency graph, separate package-graph issues from project settings, and do not rewrite manifests without explicit approval.
Search project.pbxproj for XCLocalSwiftPackageReference entries pointing to the package path, and confirm XCSwiftPackageProductDependency entries link it to at least one target. Packages on disk but not referenced should not be included in recommendations.
Use the helper script (check_spm_pins.py) to scan for available tags. If tags exist, recommend pinning to a specific version for determinism. If no tags exist, pin to a specific commit hash instead.
No. Modular targets increase SwiftCompile, SwiftEmitModule, and ScanDependencies tasks. Only recommend modular migration for build speed if the project compiles large unused portions of a monolithic SDK that modular targets can skip entirely. Benchmark both configurations first.
If the main problem is not package-related, hand off to xcode-project-analyzer (for project settings) or xcode-compilation-analyzer (for compilation issues) by reading their SKILL.md and applying their workflow to the same context.
Full instructions (SKILL.md)
Source of truth, from avdlee/xcode-build-optimization-agent-skill.
name: spm-build-analysis description: Analyze Swift Package Manager dependencies, package plugins, module variants, and CI-oriented build overhead that slow Xcode builds. Use when a developer suspects packages, plugins, or dependency graph shape are hurting clean or incremental build performance, mentions SPM slowness, package resolution time, build plugin overhead, duplicate module builds from configuration drift, circular dependencies between modules, oversized modules needing splitting, or modularization best practices.
SPM Build Analysis
Use this skill when package structure, plugins, or dependency configuration are likely contributing to slow Xcode builds.
Core Rules
- Treat package analysis as evidence gathering first, not a mandate to replace dependencies.
- Separate package-graph issues from project-setting issues.
- Do not rewrite package manifests or dependency sources without explicit approval.
What To Inspect
Package.swiftandPackage.resolved- local packages vs remote packages
- package plugin and build-tool usage
- binary target footprint
- dependency layering, repeated imports, and potential cycles
- build logs or timing summaries that show package-related work
Verification Before Recommending
Before including any local package in a recommendation, verify that it is actually part of the project's dependency graph. A Vendor/ directory may contain packages that are not linked to any target.
- Check
project.pbxprojforXCLocalSwiftPackageReferenceentries that reference the package path. - Check
XCSwiftPackageProductDependencyentries to confirm the package's product is linked to at least one target. - If a local package exists on disk but is not referenced in the project, do not include it in build-time recommendations.
When recommending version pins for branch-tracked dependencies:
- Use the helper script to scan all branch-pinned dependencies at once:
This checkspython3 scripts/check_spm_pins.py --project App.xcodeprojgit ls-remote --tagsfor each branch-pinned package and reports which have tags available for pinning. - If no tags exist, recommend pinning to a specific commit revision hash for determinism instead.
- Note which packages are branch-pinned because the upstream simply has no tags, versus packages that have tags but are intentionally tracking a branch.
Focus Areas
- package graph shape and how much work changes trigger downstream
- plugin overhead during local development and CI
- checkout or fetch cost signals that show up in clean environments
- configuration drift that forces duplicate module builds
- risks from package targets that use different macros or options while sharing dependencies
- dependency direction violations (features depending on each other instead of shared lower layers)
- circular dependencies between modules (extract shared contracts into a protocol module)
- oversized modules (200+ files) that widen incremental rebuild scope
- umbrella modules using
@_exported importthat create hidden dependency chains - missing interface/implementation separation that blocks build parallelism
- test targets depending on the app target instead of the module under test
- Swift macro rebuild cascading: heavy use of Swift macros (e.g., TCA, swift-syntax-based libraries) can cause a trivial source change to cascade into near-full rebuilds because macro expansion invalidates downstream modules
swift-syntaxbuilding universally (all architectures) when no prebuilt binary is available, adding significant clean-build overhead- multi-platform build multiplication: adding a secondary platform target (e.g., watchOS) can cause shared SPM packages to build multiple times (e.g., iOS arm64, iOS x86_64, watchOS arm64), multiplying
SwiftCompile,SwiftEmitModule, andScanDependenciestasks
Modular SDK Migration Caveat
Migrating a dependency from a monolithic target to a modular multi-target SDK (e.g., replacing one umbrella library with separate Core, RUM, Logs, Trace modules) does not automatically reduce build time. Modular targets increase the number of SwiftCompile, SwiftEmitModule, and ScanDependencies tasks because each target must be compiled, scanned, and emit its module independently. The build-time trade-off depends on the project's parallelism headroom and how many of the modular targets are actually needed.
When considering a modular SDK migration:
- Compare the total
SwiftCompiletask count before and after. - Benchmark both configurations before recommending the migration for build speed.
- If the motivation is API surface reduction (importing only what you use), note that build time may stay flat or increase while import hygiene improves.
- Only recommend modular SDK migration for build speed when the project currently compiles large portions of the monolithic SDK that it does not use, and the modular alternative lets it skip those unused portions entirely.
Explicit Module Dependency Angle
When the same module appears multiple times in timing output, investigate whether different package or target options are forcing extra module variants. Uniform options often matter more than shaving a small amount of source code.
Reporting Format
For each finding, include:
- evidence
- affected package or plugin
- likely clean-build vs incremental-build impact
- CI impact if relevant
- estimated impact
- approval requirement
If the main problem is not package-related, hand off to xcode-project-analyzer or xcode-compilation-analyzer by reading the target skill's SKILL.md and applying its workflow to the same project context.
Additional Resources
- For the detailed audit checklist, see references/spm-analysis-checks.md
- For the shared recommendation structure, see references/recommendation-format.md
- For source citations, see references/build-optimization-sources.md
Related skills
More from avdlee/xcode-build-optimization-agent-skill and the wider catalog.

xcode-build-benchmark
Benchmark Xcode clean and incremental builds with repeatable inputs and timestamped artifacts.

xcode-build-fixer
Apply approved Xcode build optimizations and verify improvements with benchmarking.

xcode-build-orchestrator
End-to-end Xcode build optimization: benchmark, analyze, prioritize, approve, fix, and re-benchmark.

xcode-compilation-analyzer
Analyze Swift compile hotspots and generate source-level optimization recommendations from build timing data.

xcode-project-analyzer
Audit Xcode project configuration, build settings, and schemes to identify build-time improvements with approval gates.

bkt
Bitbucket CLI for Data Center and Cloud. Use when users need to manage repositories, pull requests, branches, issues, webhooks, or pipelines in Bitbucket. Triggers include "bitbucket", "bkt", "pull request", "PR", "repo list", "branch create", "Bitbucket Data Center", "Bitbucket Cloud", "keyring timeout".