Skip to content

Use executableTarget in generated new executable packages #3263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions Sources/Workspace/InitPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import PackageModel
/// Create an initial template package.
public final class InitPackage {
/// The tool version to be used for new packages.
public static let newPackageToolsVersion = ToolsVersion(version: "5.3.0")
public static let newPackageToolsVersion = ToolsVersion.currentToolsVersion

/// Options for the template package.
public struct InitPackageOptions {
Expand Down Expand Up @@ -186,18 +186,34 @@ public final class InitPackage {
""")

if packageType == .library || packageType == .executable || packageType == .manifest {
pkgParams.append("""
var param = ""

param += """
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(

"""
if packageType == .executable {
param += """
.executableTarget(
"""
} else {
param += """
.target(
"""
}
param += """

name: "\(pkgname)",
dependencies: []),
.testTarget(
name: "\(pkgname)Tests",
dependencies: ["\(pkgname)"]),
]
""")
"""

pkgParams.append(param)
}

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