Hi Guys im trying to build my swift-calculator GUI apps but i get the error...
error: 'swift-calculator': product 'swift-win32' required by package 'swift-calculator' target 'swift-calculator' not found.
here my Package.swift :
import PackageDescription
let package = Package(
name: "swift-calculator",
dependencies: [
.package(name: "swift-win32", url: "https://github.com/compnerd/swift-win32.git", .branch("main")),
],
targets: [
.executableTarget(
name: "swift-calculator",
dependencies: ["swift-win32",
.product(name: "swift-calculator", package: "swift-win32")],
sources: ["main.swift"]
),
]
)
I don't know what's wrong here :(
sliemeobn
(Simon Leeb)
September 11, 2023, 12:39pm
2
looking at the Package.swift of swift-win32
products: [
.library(name: "SwiftWin32", type: .dynamic, targets: ["SwiftWin32"]),
.library(name: "SwiftWin32UI", type: .dynamic, targets: ["SwiftWin32UI"]),
.executable(name: "UICatalog", targets: ["UICatalog"]),
.executable(name: "Calculator", targets: ["Calculator"]),
],
the dependencies of your target should probably read more like this (you need to use the exposed product names there):
dependencies: [
.product(name: "SwiftWin32", package: "swift-win32"),
.product(name: "SwiftWin32UI", package: "swift-win32"),
]
1 Like
ok so i have added this but the error still same
Here is my Package.swift
// swift-tools-version: 5.8
import PackageDescription
let package = Package(
name: "swift-calculator",
dependencies: [
.package(name: "swift-win32", url: "https://github.com/compnerd/swift-win32.git", .branch("main")),
],
targets: [
.executableTarget(
name: "swift-calculator",
dependencies: ["swift-win32",
.product(name: "swift-calculator", package: "swift-win32"),
.product(name: "SwiftWin32", package: "swift-win32"),
.product(name: "SwiftWin32UI", package: "swift-win32")],
sources: ["main.swift"]
),
]
)
Is there any flags i need to add ? I'm new to this...
sliemeobn
(Simon Leeb)
September 11, 2023, 1:15pm
4
try this:
let package = Package(
name: "swift-calculator",
dependencies: [
.package(name: "swift-win32", url: "https://github.com/compnerd/swift-win32.git", .branch("main")),
],
targets: [
.executableTarget(
name: "swift-calculator",
dependencies: [
.product(name: "SwiftWin32", package: "swift-win32"),
.product(name: "SwiftWin32UI", package: "swift-win32")],
// sources: ["main.swift"]
),
]
)
also, the "sources" bit is intended to be a folder, and you don't need it if you stick to the default of Sources/<target-name>
. so if put your files under Sources/swift-calculator
and get rid of the sources
value you will be more aligned with the defaults.
1 Like
Um yes that's fixed my error... Thank you so much
1 Like
xwu
(Xiaodi Wu)
September 11, 2023, 1:42pm
6
Hi @CommandX , for questions on using Swift, the most appropriate forum category is “Using Swift.” I’ve moved your topics over there.