Skip to content

fix: match Swift frameworks by repository name in package URLs - #598

Open
17302513901yh-lang wants to merge 1 commit into
vibgrate:mainfrom
17302513901yh-lang:fix/swift-framework-repo-names
Open

17302513901yh-lang wants to merge 1 commit into
vibgrate:mainfrom
17302513901yh-lang:fix/swift-framework-repo-names

Conversation

@17302513901yh-lang

Copy link
Copy Markdown

What was wrong

KNOWN_SWIFT_FRAMEWORKS in src/core-open/scanners/swift-scanner.ts is looked
up with the dependency name lowercased (dep.name.toLowerCase(), where
dep.name is the last path segment of the package URL). Two entries were
spelled so they could never match:

  • 'snapshotTesting' — has an uppercase letter, and the repository is
    swift-snapshot-testing, not snapshotTesting.
  • 'swiftlog' — the repository is swift-log.

So a Package.swift depending on
https://github.com/pointfreeco/swift-snapshot-testing.git or
https://github.com/apple/swift-log.git never reported SnapshotTesting or
SwiftLog under detected frameworks.

What changed

src/core-open/scanners/swift-scanner.ts

  • 'snapshotTesting' → 'swift-snapshot-testing'
  • 'swiftlog' → 'swift-log'
  • documented that keys are the lowercased repository names taken from package
    URLs, and exported the map so a test can guard that invariant
  • the other entries were checked against their repository names
    (alamofire, apollo-ios, sqlite.swift, grdb.swift, cocoalumberjack,
    …) and are already correct

Tests

New src/core-open/scanners/swift-scanner.test.ts (2 cases, both passing):

  1. every key in KNOWN_SWIFT_FRAMEWORKS equals its lowercase form, so a
    camelCase or otherwise mis-cased key fails the build
  2. a temporary Package.swift depending on swift-snapshot-testing and
    swift-log reports SnapshotTesting and SwiftLog as frameworks
✓ |unit| src/core-open/scanners/swift-scanner.test.ts (2 tests) 38ms

tsc --noEmit and eslint are clean for the touched files.

Fixes #585

Framework detection lowercases the last path segment of the package URL and looks it up in KNOWN_SWIFT_FRAMEWORKS, but two entries were spelled so they could never match: 'snapshotTesting' had an uppercase letter (and the repository is swift-snapshot-testing), and 'swiftlog' is not the repository name swift-log. Projects depending on SwiftSnapshotTesting or SwiftLog therefore never reported those frameworks.

Key the map on the lowercased repository names used in package URLs, and add tests: one asserting every key is lowercase, and one scanning a Package.swift that depends on swift-snapshot-testing and swift-log.

Fixes vibgrate#585

Signed-off-by: 17302513901yh-lang <17302513901yh@gmail.com>
@vibgrate-team

Copy link
Copy Markdown
Contributor

Automated review: passed ✅

Thanks @17302513901yh-lang, nice catch! Those two keys could never match the lowercased repository name, so SnapshotTesting and SwiftLog were silently missing from detected frameworks. The fix is small and well targeted, and the new tests guard the invariant nicely.

What we checked:

  • Rebased onto current main (including the recent Swift Package.swift parsing changes in fix(swift): parse Package.swift ranges, name-first calls, and registry ids #594): merges cleanly with no overlap.
  • Reverting the fix makes both new tests fail, so they genuinely cover the bug.
  • Typecheck, lint and the full test suite pass on Node 24 (565 files, 5677 tests).
  • No regex, workflow, script or dependency changes, and no line-ending churn.

A maintainer will take it from here. Thanks again for contributing to Vibgrate!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Swift framework detection never matches SnapshotTesting or SwiftLog

2 participants