I'm trying to exclude directories based on a macro condition. The simple example below does not work. It completely ignores the macros and includes all the files:
let package = Package(
name: "MyLibrary",
platforms: [
.iOS(.v11),
.watchOS(.v4)
],
products: [
.library(
name: "MyLibrary",
targets: ["MyLibrary"]
)
],
targets: [
.target(
name: "MyLibrary",
dependencies: [],
exclude: {
var exclude: [String] = []
#if os(iOS)
exclude.append("Platforms/iOS")
exclude.append("Platforms/watchOS")
#endif
#if os(watchOS)
exclude.append("Platforms/iOS")
exclude.append("Platforms/watchOS")
#endif
return exclude
}()
),
.testTarget(
name: "MyLibraryTests",
dependencies: ["MyLibrary"]
)
]
)
It should not compile when building for an iOS or watchOS app, but it ignores the excludes and compiles fine. Is there another macro condition I should use in the manifest or is this a known issue?