Skip to content

Swift: --deps only resolves module-level imports, so intra-target file edges are missing #188

Description

@JordanCoin

Problem

On a Swift iOS app (single app target, ~1450 Swift files), codemap --deps produces almost no edges. Example output on an integrations directory:

CustomerIO ═════════════════════════════════════════════════
  +4 standalone files

7 files · 15 functions · 0 deps
  Coverage: partial — Swift (7 files): imports name modules, not files, and same-package files need no import: intra-project edges need symbol-reference resolution and are not represented

The coverage note is honest about why: Swift import statements name modules, and files in the same target reference each other with no import at all. So for the dominant iOS repo shape (one big app target), --deps can't answer the question it's best at elsewhere: "who touches this hub file?"

Concrete miss: an analytics facade file (Analytics.swift-style, enum + static funcs) called from ~20 view/viewmodel files across the target shows as a standalone node with zero importers, and --importers on it reports "No files import this file." Grep remains the sharper tool for exactly the hub-impact question codemap is designed for.

Suggestion

Intra-target edges need symbol-reference resolution rather than import parsing. Options, roughly in order of effort:

  1. ast-grep-based identifier matching (already a dependency for --deps): index top-level declared symbols per file (types, top-level funcs, enum names), then scan other files in the same target for references to those identifiers. Heuristic but catches the common TypeName.member / initializer-call patterns that make up most Swift cross-file references.
  2. SourceKit / indexstore-db: read the compiler's index store (.build/DerivedData Index.noindex) when present — exact references, but requires a prior build and adds a heavyweight dependency.

Even the heuristic version (1) would move Swift coverage from "module imports only" to useful hub detection, and false positives are acceptable for a brain-map tool — over-connecting a hub is better than showing it standalone.

Environment

  • codemap 4.5.1 (Homebrew, jordancoin/tap)
  • macOS, Swift/Xcode project, single app target + test target

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions