I have a Swift Package that produces an executable target. The executable target depends on product A from a local swift package. A has a binary dependency named B. I use B & A in the executableTarget and I can build and run from Xcode without issue. However, I get error: no such module 'B'
when I attempt to build the executable target from the command line swift build
.
B is a static library wrapped in an XCFramework.
Setup:
let package = Package(
name: "MyExecutable",
platforms: [.macOS("12.0")],
products: [
.executable(name: "MyExecutable", targets: ["MyExecutable"])
],
dependencies: [
.package(name: "MyLocalPackage", path: "../..")
],
targets: [
.executableTarget(
name: "MyExecutable",
dependencies: [
.product(name: "A", package: "MyLocalPackage")
]
)
]
)
let package = Package(
name: "MyLocalPackage",
platforms: [.macOS("12.0")],
products: [
.library(
name: "A",
targets: ["A"])
],
targets: [
.target(
name: "A",
dependencies: ["B"]
),
.binaryTarget(
name: "B",
url: "https://url/to/some/remote/xcframework.zip",
checksum: "The checksum of the ZIP archive that contains the XCFramework."
)
]
)
Do I need to somehow explicitly link B
when invoking swift build
? Any help or guidance is appreciated!