Skip to content

Commit

Permalink
improve error message for deduced executableTarget (#3254)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tomerd committed Feb 11, 2021
1 parent 7e60c2f commit f2146ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/PackageLoading/PackageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public final class PackageBuilder {
default:
targetType = sources.computeTargetType()
if targetType == .executable && manifest.toolsVersion >= .v5_4 && warnAboutImplicitExecutableTargets {
diagnostics.emit(warning: "in tools version \(ToolsVersion.v5_4) and later, use 'executableTarget()' to declare executable targets")
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()'")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/PackageLoadingTests/PackageBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class PackageBuilderTests: XCTestCase {
]
)
PackageBuilderTester(manifest, in: fs) { package, diagnostics in
diagnostics.check(diagnostic: "in tools version 5.4.0 and later, use 'executableTarget()' to declare executable targets", behavior: .warning)
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)
package.checkModule("lib") { _ in }
package.checkModule("exec2") { _ in }
package.checkProduct("exec2") { product in
Expand Down

0 comments on commit f2146ac

Please sign in to comment.