Skip to content

feat: SwiftPM package-graph support (Package.swift manifest resolution) for cross-package/cross-repo edges #551

Description

@gsdali

Summary

Cross-package/cross-repo linkage is manifest-driven (pass_pkgmap.c resolves bare specifiers via package.json, go.mod, Cargo.toml, …), but Package.swift (Swift Package Manager) is not a recognized manifest — so a SwiftPM ecosystem gets zero cross-package edges. Please add SwiftPM to the package-graph resolver.

This is the SwiftPM peer of the JS-workspace (#408), Cargo-crate (#56), and umbrella workspace (#271 / #398) work — not a duplicate; SwiftPM is simply absent.

Motivation

SwiftPM ecosystems are commonly many small packages: one core library + N consumers. The high-value query — "if I change Core.foo, which of the N consumers break?" — needs cross-package edges. Concrete real case: an ~17-package ecosystem (a binary-wrapper core + 13 consumers) where this is the daily question.

What's needed

  1. Manifest resolution (the achievable, pattern-matching ask): parse Package.swift to map module/product names → packages:
    • dependencies: .package(url: "…/Foo.git", …) and .package(path: "../Foo")
    • target deps: .product(name: "Foo", package: "Foo") and target-name deps
    • then resolve Swift import Foo to the providing package → emit cross-package IMPORTS (and, where resolvable, USAGE/CALLS) edges. Mirrors the existing package.json/Cargo.toml path.
    • Caveat: Package.swift is executable Swift, not declarative — a lightweight pattern-extraction of the dependencies: / .product(...) literals (not full evaluation) covers the overwhelming majority.
  2. Swift semantic tier (larger, noted as the precision dependency): Swift is currently tree-sitter-only ("Excellent" parse tier) with no Hybrid LSP, so cross-module CALLS resolve textually (ambiguous for common method names). Precise cross-package call graphs need a Swift semantic pass — cf. the LSP requests for Julia (Feature Request: Add Hybrid LSP support for Julia #535) / Perl (Add Perl LSP-tier semantic resolution (perl_lsp.c) #459) / Rust (Rust LSP #405). Manifest-level IMPORTS edges (item 1) are valuable even without this.

Observed (v0.8.1, macOS arm64)

Indexing a SwiftPM core + 2 consumers separately: per-repo graphs are excellent (core = 18.7k nodes / 70k edges / 7,776 funcs in 8 s; accurate CALLS/IMPORTS within a repo). But default indexing emits no CROSS_* edges between them, and index_repository mode=cross-repo-intelligence is HTTP/route-oriented (cf. #523) — there's no path that links a consumer's import Core / Core.foo() to the core package's definitions.

Acceptance

SwiftPM packages indexed under one store produce cross-package IMPORTS edges resolved through Package.swift (matching the package.json / Cargo.toml behavior). Precise cross-package CALLS tracked as a follow-up dependent on Swift semantic support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestparsing/qualityGraph extraction bugs, false positives, missing edgespriority/normalStandard review queue; useful PR with ordinary maintainer urgency.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions