First, this is for the Swift 5 development branch. The error does not occur in Swift 4. What I'm not sure about is if this is a bug in the development branch, or if I'm just missing something that needs to be changed to work in Swift 5.
I am trying to build my project using my Package manifest with the Swift 5 toolchain. But my swift build -v
is resulting in:
xcrun --sdk macosx --show-sdk-path
xcrun --sdk macosx --show-sdk-platform-path
xcrun --sdk macosx --find xctest
'MyProject' /Users/username/Code/MyProject: error: executable product 'MyProject' should have exactly one executable target
When switching to the Swift 4 toolchain (and updating the Package manifest language comment) the code builds correctly. Building the targets directly in Xcode works fine even with the Swift 5 toolchain (however, this is not being built with the Package manifest).
The Package manifest appears as:
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyProject",
products: [
.executable(
name: "MyProject",
targets: ["MyProject"])
],
dependencies: [
],
targets: [
.target(
name: "MyProject",
dependencies: []),
]
)
If I remove the individual target from the executable target list, I get the error: product 'MyProject' doesn't reference any targets
.
Is there some change to how the package manifest is laid out in Swift 5 that I'm missing that's resulting in this error? Or is this a possible bug in the Swift 5 development toolchain? Or is there something else I'm missing? Thank you!
(This is using the Swift 5.0 Snapshot 2018-12-13 (a) toolchain)
(Original Swift Reddit posting)