Binary Target infer header search path

I wonder is it possible to infer header search path for c-family binary target?

Now when adding local binary target it is possible to specify header search path like this:

targets: [
        .target(
            name: "sdk",
            dependencies: [.target(name: "sdk-objc++")]
        ),
        .target(
            name: "sdk-objc++",
            dependencies: [.targetItem(name: "LibCpp", condition: .none)],
            cxxSettings: [
                .headerSearchPath("../../LibCpp.xcframework/ios-arm64/LibCpp.framework/Headers"),
            ]
        ),
        .binaryTarget(
            name: "LibCpp",
            path: "LibCpp.xcframework"
        )
    ],
    cxxLanguageStandard: .cxx14

Which isn't really good, I need to specify header search path relative to sdk-objc++ target. But alright it's an option.

But what can be solution for the following case?

targets: [
        .target(
            name: "sdk",
            dependencies: [.target(name: "sdk-objc++")]
        ),
        .target(
            name: "sdk-objc++",
            dependencies: [.targetItem(name: "LibCpp", condition: .none)],
            cxxSettings: [
                .headerSearchPath("????"), // What should go there?
            ]
        ),
        .binaryTarget(
            name: "LibCpp",
            url: "some_cdn.com/libCpp",
            checksum: "12c2"
        )
    ],
    cxxLanguageStandard: .cxx14

I know there's option to create module map an put it into Modules directory and somehow it infers path to headers inside Headers. But if headers has some header path layout, for example header inside LibCpp depends on another header and specify include like this #include some/path/to/header.h it won't work with module map, isn't it?

So I wonder is it possible to make spm get along with c-family frameworks?

2 Likes