SPM seems to ignore a parent Target's conditional when a target is nested inside it.
.target(name: "LinuxSupport", dependencies: [
"LinuxImports",
"LinuxExtensions",
]),
.systemLibrary(name: "LinuxImports"),
.target(name: "LinuxExtensions"),
With LinuxSupport
being a dep on a library marked platforms: [.linux]
.
Pretty sure this is a bug.
A workaround is to give the nested targets a conditional as well.
.target(name: "LinuxSupport", dependencies: [
.targetItem(name: "LinuxImports", condition: .when(platforms: [.linux])),
.targetItem(name: "LinuxExtensions", condition: .when(platforms: [.linux]))
]),
.target(name: "LinuxExtensions"),
.systemLibrary(name: "LinuxImports"),
However this will not work for every situation. I have the same issue with swiftWasm's support packages but those packages support macOS too with stubs as a convenience. Currently the wasm packages balloon my macOS builds by 26MB.
Is this perhaps an oversight? Or is tracking nested targets and applying the parent conditionals to them not possible for some reason?