Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix registry package swizzling when package name casing differs #8194

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fortmarek
Copy link
Contributor

Fix registry package swizzling when package name casing differs

Motivation:

When swizzling dependencies when running swift package --replace-scm-with-registry resolve, package references that have different casing don't get swizzled.

You can find an example of this scenario in the Firebase SDK that boils down to:

import PackageDescription


let package = Package(
  name: "Firebase",
  dependencies: [
    .package(
      url: "https://github.com/google/promises.git", // lowercase
      "2.4.0" ..< "3.0.0"
    ),
  ],
  targets: [
    .target(
      name: "FirebaseCrashlytics",
      dependencies: [
        .product(name: "FBLPromises", package: "Promises"), // uppercase
      ]
    )
  ]
)

The .product(name: "FBLPromises", package: "Promises")should be swizzled to use the google.promises identifier, but because of the different casing, it's not.

Modifications:

When creating the map for packages to be swizzled, make the key lowercase. When we access the map, we again use a lowercase variant of the package name, so we don't unexpectedly miss an entry because of a different casing.

Result:

Packages with different casing are swizzled when using the swift package --replace-scm-with-registry resolve command.

@MaxDesiatov
Copy link
Contributor

@swift-ci test

Copy link
Contributor

@plemarquand plemarquand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, appreciate the contribution! I just have one small comment.

Sources/Workspace/Workspace+Registry.swift Show resolved Hide resolved
@plemarquand
Copy link
Contributor

@swift-ci please test

@plemarquand
Copy link
Contributor

@swift-ci test

@fortmarek fortmarek requested a review from plemarquand January 7, 2025 17:24
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.

4 participants