I tried your suggestion, but same error. The thing is: it works fine when I move the bindings files into the target group and add "import BrainFlow" to each of them. Xcode finds the header files inside the xcframeworks via the bridging header. But if the bindings remain inside the Package, then I get a warning at the import statements that the binding is already part of BrainFlow and therefore cannot import BrainFlow. But when I remove the import statements, I get the "cannot find xxx in scope" errors.
I ran across a reference to an "umbrella" header. It seems to act like a bridging header. So I'm trying "umbrella" but so far no luck.
I also tried pushing the xcframeworks down into a nested sub-Package called BrainFlowLibs, and adding "import BrainFlowLibs" to all the binding source files in the parent package. The import statements compile without error, but it still cannot resolve the C headers. I am using the following module map inside BrainFlowLibs/Source/BrainFlowLibs:
module BrainFlowLibs {
umbrella header "bridge.h"
export *
link "BoardController"
link "BrainBitLib"
link "DataHandler"
link "MLModule"
}
Here is the updated parent Package:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "BrainFlow",
platforms: [
.macOS(.v10_15), .iOS(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(name: "BrainFlow",
targets: ["BrainFlow"])
],
dependencies: [
.package(name: "swift-numerics",
url: "https://github.com/apple/swift-numerics.git", .upToNextMajor(from: "1.0.0")),
.package(name: "BrainFlowLibs",
path: "BrainFlowLibs")
],
targets: [
.target(
name: "BrainFlow",
dependencies: [.product(name: "Numerics", package: "swift-numerics"),
.product(name: "BrainFlowLibs", package: "BrainFlowLibs")]
),
.testTarget(
name: "BrainFlowTests",
dependencies: ["BrainFlow", .product(name: "Numerics", package: "swift-numerics")],
sources: ["BoardShimTests.swift",
"BrainFlowCItests.swift",
"BrainFlowTests.swift",
"DataFilterTests.swift"]
)
]
)
And here is the new sub-Package:
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "BrainFlowLibs",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "BrainFlowLibs",
targets: ["BrainFlowLibs","BoardController", "DataHandler", "MLModule", "BrainBitLib"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "BrainFlowLibs",
dependencies: []),
.binaryTarget(
name: "BoardController",
path: "BoardController.xcframework"
),
.binaryTarget(
name: "DataHandler",
path: "DataHandler.xcframework"
),
.binaryTarget(
name: "MLModule",
path: "MLModule.xcframework"
),
.binaryTarget(
name: "BrainBitLib",
path: "BrainBitLib.xcframework"
),
.testTarget(
name: "BrainFlowLibsTests",
dependencies: ["BrainFlowLibs"]),
]
)
--Scott