Skip to content

feat(ffi): add Swift support#96

Merged
qzhuyan merged 5 commits intomainfrom
dev/ffi-swift
Apr 26, 2026
Merged

feat(ffi): add Swift support#96
qzhuyan merged 5 commits intomainfrom
dev/ffi-swift

Conversation

@qzhuyan
Copy link
Copy Markdown
Collaborator

@qzhuyan qzhuyan commented Apr 17, 2026

Description

Please include a summary of the changes and which issue is fixed. Please also include relevant motivation and context.

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Performance Impact

  • This change improves performance
  • This change has no performance impact
  • This change may have performance implications (please describe)

Security Considerations

  • This change has no security implications
  • This change has security implications (please describe)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.90%. Comparing base (5b755ac) to head (f1971de).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
- Coverage   76.90%   76.90%   -0.01%     
==========================================
  Files          66       66              
  Lines       17065    17064       -1     
==========================================
- Hits        13124    13123       -1     
  Misses       3941     3941              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Swift support for FlowSDK via UniFFI-generated Swift/C bindings, including an SPM package layout, example clients, and CI verification to ensure bindings can be generated and compiled.

Changes:

  • Add UniFFI-generated Swift bindings (FlowSDK) and C bridging header target (flowsdk_ffi) for Swift Package Manager.
  • Add Swift TCP + QUIC example executables and a Swift README with build/run instructions.
  • Add scripts/build_swift_bindings.sh, CI job to generate+build Swift, and .gitignore entries for Swift build artifacts.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
swift/Sources/flowsdk_ffi/flowsdk_ffi.h Adds generated C FFI header for Swift bridging target.
swift/Sources/FlowSDK/flowsdk_ffi.swift Adds generated Swift UniFFI bindings exposing the Rust API to Swift.
swift/Package.swift Defines SPM package targets/products for the bindings + examples.
swift/README.md Documents generating bindings and building/running Swift examples.
swift/Examples/TcpClientExample/main.swift Adds a TCP MQTT example that drives the engine with POSIX sockets.
swift/Examples/QuicClientExample/main.swift Adds a QUIC MQTT example that drives the engine with UDP sockets.
scripts/build_swift_bindings.sh Adds script to build Rust + generate/distribute Swift bindings, optionally verify build/XCFramework.
src/mqtt_client/engine.rs Refactors QUIC Connected event handling using a match guard.
examples/no_io_tokio_quic_client_example.rs Refactors match arms using guards for subscribe/publish flow.
.gitignore Ignores Swift build outputs, generated artifacts, and Python egg-info.
.github/workflows/ci.yml Adds a macOS Swift bindings job and extends target matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread swift/Sources/FlowSDK/flowsdk_ffi.swift Outdated
Comment thread swift/Examples/QuicClientExample/main.swift
Comment thread swift/Examples/QuicClientExample/main.swift Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +45 to +49
let rc = Darwin.connect(fd, ai.pointee.ai_addr, ai.pointee.ai_addrlen)
if rc < 0 && errno != EINPROGRESS {
fatalError("connect() failed: \(String(cString: strerror(errno)))")
}
return fd
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is intended to work on macOS/Linux, but it calls Darwin.connect(...). On Linux (Glibc) the Darwin module isn't available, so this won't compile. Use connect(...) directly (or conditionally call Darwin.connect vs Glibc.connect).

Copilot uses AI. Check for mistakes.
Comment thread swift/Examples/TcpClientExample/main.swift
Comment thread swift/Examples/TcpClientExample/main.swift Outdated
Comment thread swift/Examples/TcpClientExample/main.swift
Comment thread .github/workflows/ci.yml
retention-days: 7

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
@qzhuyan qzhuyan marked this pull request as ready for review April 21, 2026 14:18
@qzhuyan qzhuyan merged commit 9143601 into main Apr 26, 2026
31 checks passed
@qzhuyan qzhuyan deleted the dev/ffi-swift branch May 5, 2026 12:01
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.

4 participants