I am using the swift package manager.
I have a module ModuleA which exports two types: ModuleA and Test.
I have a module ModuleB which defines a single type: Test.
In ModuleB, how can I refer to the type Test from ModuleA?
Ideally, I would like syntax such as #module(ModuleA) to refer directly to the module ModuleA.
Reproducible example:
Package.swift:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "ShadowingTest",
products: [
.library(
name: "ModuleA",
targets: ["ModuleA"]),
.library(
name: "ModuleB",
targets: ["ModuleB"]),
],
dependencies: [
],
targets: [
.target(
name: "ModuleA",
dependencies: []),
.target(
name: "ModuleB",
dependencies: ["ModuleA"]),
]
)
Sources/ModuleA/ModuleA.swift:
public enum ModuleA {}
public struct Test {
public static let module: String = "ModuleA"
}
Sources/ModuleB/ModuleB.swift:
import ModuleA
struct Test {
static let module: String = "ModuleB"
}
func test() {
print(ModuleA.Test.module)
}
Running swift build errors with
Sources/ModuleB/ModuleB.swift:8:19: error: type 'ModuleA' has no member 'Test'
but succeeds when public is removed from the ModuleA enum in ModuleA.