Skip to content

Commit f2146ac

Browse files
authored
improve error message for deduced executableTarget (#3254)
motivation: include the name of the target in the warning so its more actionable changes: add the target name in the "use executableTarget in 5.4" warning rdar://74045851
1 parent 7e60c2f commit f2146ac

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ public final class PackageBuilder {
752752
default:
753753
targetType = sources.computeTargetType()
754754
if targetType == .executable && manifest.toolsVersion >= .v5_4 && warnAboutImplicitExecutableTargets {
755-
diagnostics.emit(warning: "in tools version \(ToolsVersion.v5_4) and later, use 'executableTarget()' to declare executable targets")
755+
diagnostics.emit(warning: "'\(potentialModule.name)' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version \(ToolsVersion.v5_4) executable targets should be declared as 'executableTarget()'")
756756
}
757757
}
758758

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class PackageBuilderTests: XCTestCase {
482482
]
483483
)
484484
PackageBuilderTester(manifest, in: fs) { package, diagnostics in
485-
diagnostics.check(diagnostic: "in tools version 5.4.0 and later, use 'executableTarget()' to declare executable targets", behavior: .warning)
485+
diagnostics.check(diagnostic: "'exec2' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'", behavior: .warning)
486486
package.checkModule("lib") { _ in }
487487
package.checkModule("exec2") { _ in }
488488
package.checkProduct("exec2") { product in

0 commit comments

Comments
 (0)