let package = Package(
name: "WebGrep",
platforms: [.macOS(.v14)],
products: [
.executable(name: "webgrep", targets: ["WebGrep"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
.package(url: "https://github.com/scinfu/SwiftSoup.git", .upToNextMajor(from: "2.6.1")),
.package(url: "https://github.com/pakLebah/ANSITerminal", from: "0.0.3"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.executableTarget(
name: "WebGrep",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
.product(name: "ANSITerminal", package: "ANSITerminal"),
]
),
]
)
After I added the products arg, I can't find the executable. where is it?
Compile with Xcode doesn't output any executable to where Product/Show Build Folder in Finder
Run inside Xcode now:
Could not launch “WebGrep”
Could not launch “WebGrep”
Domain: IDELaunchErrorDomain
Code: 20
Recovery Suggestion: The LaunchServices launcher has returned an error. Please check the system logs for the underlying cause of the error.
If I comment out products: parameter, I can Run inside Xcode.
So this tells me I should not pass products: parameter. This allows for build/run inside Xcode and swift build on command line.
I think, the last two products are giving you the grief.
I can run the executable produced by the following Package.swift, from the Terminal and the Xcode.
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "WebGrep",
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.executableTarget(
name: "WebGrep",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
]
)