Skip to content

Commit 88f5dcb

Browse files
committed
Use executableTarget in generated new executable packages
1 parent 0daea76 commit 88f5dcb

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 {
@@ -186,18 +186,34 @@ public final class InitPackage {
186186
""")
187187

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

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

0 commit comments

Comments
 (0)