Depending on packages that contain binary targets

I am currently writing a swift package that statically links against a C library, but I am running into issues when trying to depend on it in an Xcode project.

  1. Bundling the C library as a XCFramework and declaring it a binaryTarget works fine, but the package cannot depend on multiple XCFrameworks that declare modules because it leads to file conflicts of the module.modulemap files. This only seems to be a problem when building via Xcode, and not when using SwiftPM directly
  2. Bundling the C library as an artifactbundle and declaring it a binaryTarget works great with swift packages, but when I try include a package that depends (directly or indirectly via intermediate packages) on such a binary target the module(s) declared by the artifactbundle cannot be resolved

For reference:

Package.swift:

// swift-tools-version: 6.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "LuaJITSwift",
    products: [
        .library(
            name: "LuaJITSwift",
            type: .static,
            targets: ["LuaJITSwift"]
        ),
    ],
    targets: [
        .binaryTarget(
            name: "LuaJIT",
            path: "LuaJIT.artifactbundle"
        ),
        .target(
            name: "LuaJITSwift",
            dependencies: ["LuaJIT"]
        ),
        .testTarget(
            name: "LuaJITSwiftTests",
            dependencies: ["LuaJITSwift"],
        )
    ],
    swiftLanguageModes: [.v6]
)

LuaJIT.artifactbundle/info.json:

{
    "schemaVersion": "1.0",
    "artifacts": {
        "luaJIT": {
            "version": "2.1",
            "type": "staticLibrary",
            "variants": [
                {
                    "path": "luaJIT/macos-arm64/libluajit.a",
                    "supportedTriples": [
                        "arm64-apple-macos"
                    ],
                    "staticLibraryMetadata": {
                        "headerPaths": [
                            "luaJIT/macos-arm64/include"
                        ],
                        "moduleMapPath": "luaJIT/macos-arm64/include/module.modulemap"
                    }
                },
                {
                    "path": "luaJIT/macos-x86_64/libluajit.a",
                    "supportedTriples": [
                        "x86_64-apple-macos"
                    ],
                    "staticLibraryMetadata": {
                        "headerPaths": [
                            "luaJIT/macos-x86_64/include"
                        ],
                        "moduleMapPath": "luaJIT/macos-x86_64/include/module.modulemap"
                    }
                }
            ]
        }
    }
}

module.modulemap:

module LuaJIT {
    header "lua.h"
    header "luaconf.h"
    header "luajit.h"
    header "lualib.h"
    header "lauxlib.h"
    
    export *
}

Which works fine on its own and with other SwiftPM packages, but when included in an Xcode project results in

Possible workarounds I have identified so far:

  1. Declare all imports of the C module as @_implementationOnly (not ideal since the attribute is deprecated
  2. Mark the swift package as a dynamic library and add the -emit-library flag
  3. Add a copy bundle resource phase to the Xcode project for the artifactbundle (I don't understand why this is necessary since the swift package already explicitly depends on it)