There is a workaround by defining a dummy C target that includes the XCFramework. This is explained on the forum: https://forums.swift.org/t/swift-package-and-xcframework-target-for-c-library-where-to-include-the-header/51163/6
You will find a link to a sample repository that show how to architecture the project: https://github.com/withuno/UnoSwift
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "IBANKit",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "IBANKit",
targets: ["IBANKit"]),
],
dependencies: [],
targets: [
// Adds the C module as a dependencies to your C sources
.target(
name: "IBANKit",
dependencies: ["C"],
path: "Sources/IBANKit"
),
// Create a dummy c package that uses the XCFramework
.target(
name: "C",
dependencies: ["IBANChecker-Core"],
path: "Sources/C"
),
.binaryTarget(name: "IBANChecker-Core", path: "Libs/IBANChecker-Core.xcframework"),
]
)
Then create a dummy .c source:
/// Sources/C/bridge.c
#include "bridge.h"
void __dummy() {}
and a .h in:
// Sources/C/include/bridge.h
#define IBANKIT_VERSION 1
/* Here include the header of the XCFramework */
#include "IBANChecker-Core.h"
And finally in your swift file
import C
// Now uses symbols defined in the XCFramework
Post
Replies
Boosts
Views
Activity
This could be a possibility 😅 But as the WWDC video and documentation mentioned that struct should be supported, I wanted to know how it is expected to work with SwiftData.