Skip to content

Commit 635d70b

Browse files
authored
Add diagnostics to use module aliasing when duplicate targets found (#5607)
Resolves rdar://93218209
1 parent 796b7ff commit 635d70b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extension ModuleError: CustomStringConvertible {
8383
switch self {
8484
case .duplicateModule(let name, let packages):
8585
let packages = packages.joined(separator: "', '")
86-
return "multiple targets named '\(name)' in: '\(packages)'"
86+
return "multiple targets named '\(name)' in: '\(packages)'; consider using the `moduleAliases` parameter in manifest to provide unique names"
8787
case .moduleNotFound(let target, let type):
8888
let folderName = (type == .test) ? "Tests" : (type == .plugin) ? "Plugins" : "Sources"
8989
return "Source files for target \(target) should be located under '\(folderName)/\(target)', or a custom sources path can be set with the 'path' property in Package.swift"

Tests/PackageGraphTests/PackageGraphTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class PackageGraphTests: XCTestCase {
291291
)
292292

293293
testDiagnostics(observability.diagnostics) { result in
294-
result.check(diagnostic: "multiple targets named 'Bar' in: 'bar', 'foo'", severity: .error)
294+
result.check(diagnostic: "multiple targets named 'Bar' in: 'bar', 'foo'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
295295
}
296296
}
297297

@@ -350,7 +350,7 @@ class PackageGraphTests: XCTestCase {
350350
)
351351

352352
testDiagnostics(observability.diagnostics) { result in
353-
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth', 'second', 'third'", severity: .error)
353+
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth', 'second', 'third'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
354354
}
355355
}
356356

@@ -409,8 +409,8 @@ class PackageGraphTests: XCTestCase {
409409
)
410410

411411
testDiagnostics(observability.diagnostics) { result in
412-
result.check(diagnostic: "multiple targets named 'Bar' in: 'fourth', 'third'", severity: .error)
413-
result.check(diagnostic: "multiple targets named 'Foo' in: 'first', 'second'", severity: .error)
412+
result.check(diagnostic: "multiple targets named 'Bar' in: 'fourth', 'third'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
413+
result.check(diagnostic: "multiple targets named 'Foo' in: 'first', 'second'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
414414
}
415415
}
416416

@@ -476,7 +476,7 @@ class PackageGraphTests: XCTestCase {
476476
)
477477

478478
testDiagnostics(observability.diagnostics) { result in
479-
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth'", severity: .error)
479+
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
480480
}
481481
}
482482

@@ -950,7 +950,7 @@ class PackageGraphTests: XCTestCase {
950950
)
951951

952952
testDiagnostics(observability.diagnostics) { result in
953-
result.check(diagnostic: "multiple targets named 'Foo' in: 'dep2', 'start'", severity: .error)
953+
result.check(diagnostic: "multiple targets named 'Foo' in: 'dep2', 'start'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
954954
}
955955
}
956956

0 commit comments

Comments
 (0)