Skip to content

Compile BluetoothGATT and BluetoothHCI for Embedded Swift - #218

Merged
colemancda merged 2 commits into
masterfrom
feature/embedded-swift
Jul 16, 2026
Merged

Compile BluetoothGATT and BluetoothHCI for Embedded Swift#218
colemancda merged 2 commits into
masterfrom
feature/embedded-swift

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

  • Bluetooth and BluetoothGAP already compiled under Embedded Swift. This gets BluetoothGATT and BluetoothHCI compiling too.
  • GATTClient (an actor using Task/CheckedContinuation) is excluded from Embedded builds via #if !hasFeature(Embedded). GATTServer was already documented as the Embedded-friendly alternative but still used [weak self] closures — Embedded Swift disallows weak/unowned references entirely, so these were switched to plain strong captures.
  • BluetoothHostControllerInterface's ~130 async convenience extensions (one per HCI command file) are wrapped in #if !hasFeature(Embedded); the underlying HCICommandParameter structs they wrap for wire encoding remain available on Embedded. One of these extensions (an async computed default property) crashed the Embedded SILGen pass outright, confirming this whole layer isn't Embedded-ready upstream yet.
  • A handful of files had Foundation/FoundationEssentials imports or Data/TimeInterval usages not properly guarded by canImport(Foundation) — this fails to compile (not just fails to import) when Foundation doesn't exist at all, as on a genuine Embedded target.

Adds .github/workflows/swift-embedded.yml, building all four libraries (debug + release) against the official wasm32-unknown-wasip1 Embedded Swift SDK on every push.

Closes #154

Test plan

  • All four targets (Bluetooth, BluetoothGAP, BluetoothGATT, BluetoothHCI) build clean, debug and release, against the Embedded WASM SDK (Swift 6.3.2)
  • Normal (non-Embedded) swift build still succeeds
  • Full test suite (316 tests) still passes

Bluetooth and BluetoothGAP already compiled under Embedded Swift;
this extends support to BluetoothGATT and BluetoothHCI, whose async
Concurrency-based APIs and Foundation-only members needed to be
excluded from Embedded builds:

- GATTClient (an actor using Task/CheckedContinuation) is guarded
  behind #if !hasFeature(Embedded); GATTServer already documented
  itself as the Embedded-friendly alternative but still used
  [weak self] captures, which Embedded Swift disallows entirely
  (no weak/unowned support) - switched to plain strong captures.
- BluetoothHostControllerInterface's ~130 async convenience
  extensions (one per HCI command file) are wrapped in
  #if !hasFeature(Embedded); the underlying HCICommandParameter
  structs they wrap remain available. One of these (the async
  computed `default` accessor) crashed the Embedded SILGen pass
  outright, confirming the whole async-extension surface is not yet
  Embedded-compatible upstream.
- A handful of files had FoundationEssentials/Foundation imports or
  Data/TimeInterval usages that weren't properly guarded by
  canImport(Foundation), which fails to compile (not just fails to
  import) when Foundation doesn't exist at all, as on a true
  Embedded target.

Verified all four libraries build clean (debug and release) against
the official wasm32-unknown-wasip1 Embedded Swift SDK using Swift
6.3.2, and that the normal (non-Embedded) build and full test suite
are unaffected.

Adds .github/workflows/swift-embedded.yml to build all four targets
under Embedded Swift on every push.
@colemancda
colemancda merged commit fc2f102 into master Jul 16, 2026
46 checks passed
@colemancda
colemancda deleted the feature/embedded-swift branch July 16, 2026 01:13
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.

Add Embedded Swift support

1 participant