How can I include headers in an XCFramework package?

I'm trying to wrap an XCFramework as a swift package. Following the documentation, I have created a package with the following directory structure:

/MyXCFPackage
    /Package.swift
    /MyXCFPackage.xcframework
    /include <- some additional headers here

And my Package.swift looks like so:

// swift-tools-version:5.6
import PackageDescription

let package = Package(
    name: "MyXCFPackage",
    products: [
        .library(
            name: "MyXCFPackage",
            targets: ["MyXCFPackage"])
    ],
    targets: [
        .binaryTarget(
            name: "MyXCFPackage",
            path: "./MyXCFPackage.xcframework"
        )
    ]
)

The thing is, this framework was not structured originally for Swift Package Manager, and the XCFramework does not contain the headers, just the .a files for the library. As a result, when I include this package in a client project, the headers are not available.

In the instructions for the framework, it says that the /include directory should be added to the Xcode build settings under HEADER_SEARCH_PATHS .

How can I get these headers into the HEADER_SEARCH_PATHS through Swift Package Manager?

That's just not a valid XCFramework. It's not a SPM-specific thing that the XCFramework is supposed to contain the headers. I would recommend either complaining to the people producing the XCFramework or repacking it into something valid yourself.

1 Like