mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-21 00:40:16 +00:00
A SwiftPM package wrapping the timer library's native ABI behind an idiomatic `TimerNode` Swift class. `build-xcframework.sh` cross-compiles the Nim library to a static MyTimer.xcframework with three slices — ios-arm64 (device), ios-arm64-simulator, and macos-arm64 — assembling the .xcframework by hand so it works without a functioning Simulator toolchain (CI-friendly). The wrapper bridges the async FFI-thread callback to a synchronous Swift API with a semaphore and reads the typed EchoResponse struct out of the callback. The macos-arm64 slice makes the wrapper testable on the host: `swift test` passes against it. Device/simulator slices are the real iOS deployment artifacts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
843 B
Swift
23 lines
843 B
Swift
// swift-tools-version:5.9
|
|
import PackageDescription
|
|
|
|
// SwiftPM package wrapping the timer library for iOS (and macOS, so the Swift
|
|
// wrapper is testable on the host with `swift test`).
|
|
//
|
|
// `MyTimer.xcframework` is produced by ./build-xcframework.sh and bundles the
|
|
// static library for ios-arm64 (device), ios-arm64-simulator, and macos-arm64,
|
|
// each with the C headers + module map. Run the build script before
|
|
// `swift build` / `swift test`.
|
|
let package = Package(
|
|
name: "MyTimer",
|
|
platforms: [.iOS(.v13), .macOS(.v12)],
|
|
products: [
|
|
.library(name: "MyTimer", targets: ["MyTimer"])
|
|
],
|
|
targets: [
|
|
.binaryTarget(name: "CMyTimer", path: "MyTimer.xcframework"),
|
|
.target(name: "MyTimer", dependencies: ["CMyTimer"]),
|
|
.testTarget(name: "MyTimerTests", dependencies: ["MyTimer"]),
|
|
]
|
|
)
|