Skip to content

swift: add TailcatKit on the upstream C API - #64

Open
josuediazflores wants to merge 8 commits into
tailscale:mainfrom
josuediazflores:swift-bindings
Open

josuediazflores wants to merge 8 commits into
tailscale:mainfrom
josuediazflores:swift-bindings

Conversation

@josuediazflores

@josuediazflores josuediazflores commented Sep 2, 2026 •

Copy link
Copy Markdown

This reworks the Swift bindings on the C API merged in #130, as requested in the latest maintainer feedback. The previous libtailcat/ implementation is removed; the diff against current main adds only the Swift package and its README entry.

TailcatKit provides Swift 6 async servers, clients, listeners, and TCP connections for macOS 14+ and iOS 17+. It uses the upstream opaque handles, per-operation error strings, cancellation/deadline tokens, and tc_free ownership rules. Swift task cancellation interrupts pending C calls, while all blocking operations and resource teardown run off actor executors.

The Apple build scripts now package cmd/libtailcat and its public header as CTailcat.xcframework. Tests run against a local DERP/STUN relay and cover cancellation/reuse, half-close, partial writes, listener/connection ownership, key bundles, and address metadata. The README documents API changes including ephemeral listen port zero, idempotent startup, async close, and the upstream key format.

Validation:

  • go test ./...
  • go test -race ./internal/capi ./cmd/libtailcat
  • make -C swift test with Swift warnings treated as errors
  • XCFramework builds for macOS, iOS devices, and iOS simulator
  • Swift release build with warnings treated as errors
  • iOS device and simulator xcodebuild builds

The XCFramework remains a local build output; binary release distribution and UDP wrappers are not included.

@bradfitz

bradfitz commented Sep 4, 2026

Copy link
Copy Markdown
Member

I'd like a C expert to review this API first. This is why I also haven't merged my early #6

That said, it's probably pretty close since both were modeled on libtailscale's API.

@bradfitz

bradfitz commented Oct 7, 2026

Copy link
Copy Markdown
Member

Of 3 pending PRs, I ended up going with the C API from #130. But that didn't add Swift. Could you rebase/redo your Swift work atop that API?

@josuediazflores josuediazflores changed the title libtailcat, swift: add C bindings and a TailcatKit Swift package swift: add TailcatKit on the upstream C API Oct 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants