Compile BluetoothGATT and BluetoothHCI for Embedded Swift - #218
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GATTClient(anactorusingTask/CheckedContinuation) is excluded from Embedded builds via#if !hasFeature(Embedded).GATTServerwas 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 ~130asyncconvenience extensions (one per HCI command file) are wrapped in#if !hasFeature(Embedded); the underlyingHCICommandParameterstructs they wrap for wire encoding remain available on Embedded. One of these extensions (an async computeddefaultproperty) crashed the Embedded SILGen pass outright, confirming this whole layer isn't Embedded-ready upstream yet.Foundation/FoundationEssentialsimports orData/TimeIntervalusages not properly guarded bycanImport(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 officialwasm32-unknown-wasip1Embedded Swift SDK on every push.Closes #154
Test plan
Bluetooth,BluetoothGAP,BluetoothGATT,BluetoothHCI) build clean, debug and release, against the Embedded WASM SDK (Swift 6.3.2)swift buildstill succeeds