Skip to content

Conversation

@scottmarchant
Copy link

@scottmarchant scottmarchant commented Dec 12, 2025

Summary

This PR adds support for compiling sqlite-kit to wasm using the Swift SDK for WebAssembly.

This PR is part of a larger effort by a company called PassiveLogic to enable broad support for Swift WebAssembly.

Details

  • Enables WASM compilation
  • Adds configuration to compile WASM in CI
  • Introduces conditional dependency on NIOAsyncRuntime for WASI platforms only, to work around the NIOPosix dependency (which does not compile to wasm).
  • Conditionalizes the usage of NIOPosix using canImport
  • Update swift-nio dependency to a version that supports the WASI platform.

Testing done

  • Verified unit tests still pass
  • Verified no new warnings are created
  • Verified swift build --swift-sdk swift-6.3-DEVELOPMENT-SNAPSHOT-2025-12-07-a_wasm --target SQL completes without errors. This is the latest daily snapshot of the swift toolchain.
  • Verified a third-party executable can build this library as part of a larger wasm executable, and run sqlite in the browser.
  • Verified these changes compile in CI. The exception is a dependency check, which can't be completed until dependent PR's in async-kit and sqlite-nio are merged. See https://github.com/PassiveLogic/sqlite-kit/actions/runs/20180692292/job/57940103176?pr=1

Usage notes

The current Swift 6.2.x breaks certain wasm executors that make testing wasm executables like this impossible. To fully test this running in the browser, recommend using Swift 6.3.x or later.

Impact Risk

No known impact risk

PR Dependencies

The following PR's must be merged and released before this PR can be reviewed and merged. It will remain in draft state until then.

vapor/sqlite-nio#98
vapor/async-kit#111


// TODO: SM: Update below once everything is merged and release to the proper repositories
// .package(url: "https://github.com/vapor/sqlite-nio.git", from: "1.9.0"),
.package(url: "https://github.com/PassiveLogic/sqlite-nio.git", branch: "feat/swift-wasm-support-v2"),
Copy link
Author

Choose a reason for hiding this comment

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

Note that this PR is in Draft until the listed dependent PR's are merged and released. I'll update this diff and move the PR out of draft once required dependency PR's are in order.

Copy link
Author

Choose a reason for hiding this comment

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

@scottmarchant scottmarchant force-pushed the feat/swift-wasm-support-v2 branch from 7e945df to 4dae104 Compare December 16, 2025 01:02
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.

1 participant