Skip to content

Package-level module aliases are not applied #6911

@fumoboy007

Description

@fumoboy007

Description

I have a package that needs to alias a dependency’s module due to conflicting module names.

Currently, I am doing this at the product level like so:

.product(name: "MessagePack", package: "MessagePack", moduleAliases: [
   "MessagePack": "FlightSchoolMessagePack",
]),

This works, but I would like to do the alias at the package level like so:

let flightSchoolMessagePackDependency: PackageDescription.Package.Dependency =
   .package(url: "https://github.com/Flight-School/MessagePack.git", from: "1.2.4")
flightSchoolMessagePackDependency.moduleAliases = ["MessagePack": "FlightSchoolMessagePack"]

let package = Package(
   
   dependencies: [
      flightSchoolMessagePackDependency,
   
)

Expected behavior

I expect the package-level module alias to be applied, similar to the product-level module alias.

Actual behavior

The package manager returns an error:

multiple targets named 'MessagePack' in: 'messagepack', 'msgpack-swift'; consider using the moduleAliases parameter in manifest to provide unique names

Steps to reproduce

  1. Download my package.
  2. Switch to the with-flight-school-dep branch.
  3. Replace the dependency .package(url: "https://github.com/Flight-School/MessagePack.git", from: "1.2.4") with a similar dependency that has the moduleAliases property specified.
  4. Remove the moduleAliases parameter from .product(name: "MessagePack", package: "MessagePack", moduleAliases: …).
  5. swift build

Swift Package Manager version/commit hash

swift-5.8.1-RELEASE

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
Darwin Darrens-Mac.momahome 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions