Skip to content

Commit aa681bd

Browse files
authored
Use executableTarget in generated new executable packages (#3263)
1 parent 4632dd5 commit aa681bd

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Sources/Workspace/InitPackage.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import PackageModel
1515
/// Create an initial template package.
1616
public final class InitPackage {
1717
/// The tool version to be used for new packages.
18-
public static let newPackageToolsVersion = ToolsVersion(version: "5.3.0")
18+
public static let newPackageToolsVersion = ToolsVersion.currentToolsVersion
1919

2020
/// Options for the template package.
2121
public struct InitPackageOptions {
@@ -187,18 +187,34 @@ public final class InitPackage {
187187
""")
188188

189189
if packageType == .library || packageType == .executable || packageType == .manifest {
190-
pkgParams.append("""
190+
var param = ""
191+
192+
param += """
191193
targets: [
192194
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
193195
// Targets can depend on other targets in this package, and on products in packages this package depends on.
194-
.target(
196+
197+
"""
198+
if packageType == .executable {
199+
param += """
200+
.executableTarget(
201+
"""
202+
} else {
203+
param += """
204+
.target(
205+
"""
206+
}
207+
param += """
208+
195209
name: "\(pkgname)",
196210
dependencies: []),
197211
.testTarget(
198212
name: "\(pkgname)Tests",
199213
dependencies: ["\(pkgname)"]),
200214
]
201-
""")
215+
"""
216+
217+
pkgParams.append(param)
202218
}
203219

204220
stream <<< pkgParams.joined(separator: ",\n") <<< "\n)\n"

0 commit comments

Comments
 (0)