[ad_1]
I’m attempting to construct a Swift bundle, the place one of many targets should rely upon a special model of a library relying on whether or not it’s being constructed for iOS or MacOS.
For iOS, the dependency is packaged as an .xcframework, whereas for MacOS it’s packaged as a system library.
So my dependencies bundle seems to be like this:
// swift-tools-version:5.6
import PackageDescription
let bundle = Package deal(
title: "LibFoo",
merchandise: [
.library(name: "LibFooFramework", targets: ["LibFooFramework"]),
.library(title: "ClibFoo", targets: ["ClibFoo"])
],
targets: [
.binaryTarget(
name: "LibFooFramework",
path: "path/to/LibFooFramework.xcframework"
),
.systemLibrary(
name: "ClibFoo",
pkgConfig: "libFoo"
)
]
)
So then in my consumer bundle, I wish to use one in every of these dependencies relying on the goal platform.
I’ve tried this:
// swift-tools-version:5.6
import PackageDescription
#if os(iOS)
let conditionalTarget: Goal = .goal(
title: "MyLib",
dependencies: [
.product(name: "LibFooFramework", package: "LibFooFramework")
]
)
#else
let CVulkanUtilsTarget: Goal = .goal(
title: "MyLib",
dependencies: [
.product(name: "ClibFoo", package: "LibFoo")
]
)
#endif
let bundle = Package deal(
title: "MyLib",
merchandise: [
.library(name: "MyLib", targets: ["MyLib"]),
],
dependencies: [
.package(url: "https://github.com/spencerkohan/LibFoo", branch:"master")
],
targets: [
.library(
name: "LibFooFramework",
path: "path/to/LibFooFramework.xcframework"
),
]
)
However it appears that evidently the bundle supervisor at all times takes the else department, even when the bundle is being constructed for iOS. I suppose it is because the os goal of the Package deal.swift will at all times be the construct atmosphere and never the goal.
However is there any strategy to obtain this kind of conditional dependency?
[ad_2]
