Import the embedded Foundation shim in AdvertisementData - #49
Merged
Conversation
The 128-bit service class UUID lists decode into `UUID`, but this file only
imported Bluetooth and BluetoothGAP, so under Embedded Swift the type had no
declaring module in scope:
struct 'UUID' cannot be used in an embedded function not marked
'@export(interface)' because 'FoundationEmbedded' was not imported
It goes unnoticed building the target on its own, since BluetoothGAP isn't
present and the `canImport(BluetoothGAP)` block compiles out. It only shows up
once something else in the graph pulls BluetoothGAP in - a GATT server, for
instance - which is how the embedded CI matrix misses it.
Uses the same conditional import BluetoothGAP itself uses for the type it
hands back.
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.
Problem
AdvertisementData.swiftdecodes the 128-bit service class UUID lists intoUUID, but only importsBluetoothandBluetoothGAP. Under Embedded Swift that leaves the type with no declaring module in scope:Why CI doesn't catch it
The embedded job builds
--target GATTon its own.BluetoothGAPisn't in the graph, so the whole#if canImport(BluetoothGAP)block compiles out and the offending lines are never type-checked.It only surfaces once something else in the dependency graph pulls
BluetoothGAPin — a package building a GATT server, for instance. In that configuration the block is live and the module fails to build (13 errors, all in this file).Might be worth adding a matrix case that builds a small consumer rather than the target alone, otherwise this class of bug stays invisible.
Fix
Adds the same conditional Foundation import that
BluetoothGAPitself uses for the type it hands back — seeSources/BluetoothGAP/GAPCompleteListOf128BitServiceClassUUIDs.swift.Verification
BluetoothGAP: 13 errors → 0swift build --target GATT --swift-sdk swift-6.3.3-RELEASE_wasm-embedded: cleanswift build --traits BluetoothGATT: cleanswift test: 7/7 passingThe last two matter because adding a Foundation import is exactly the kind of change that can regress a non-embedded build.