Skip to content

Embedded Swift support#9

Merged
colemancda merged 35 commits into
masterfrom
feature/embedded
Jul 18, 2026
Merged

Embedded Swift support#9
colemancda merged 35 commits into
masterfrom
feature/embedded

Conversation

@colemancda

Copy link
Copy Markdown
Member

Overview

Removes the runtime Codable-based TLVEncoder/TLVDecoder and replaces it with explicit TLV coding compatible with Embedded Swift, following the same design as CoreModel.

Changes

  • TLVEncodable / TLVDecodable no longer refine Encodable / Decodable; conformances implement var tlvData: Data and init?(tlvData:) directly.
  • New TLVContainer type for keyed encoding and decoding of structured types via TLVCodingKey.
  • Primitive conformances for integers, Bool, Float, Double, String, Data, and arrays, plus RawRepresentable default implementations. Wire format is unchanged: little-endian, Int/UInt as 32-bit, arrays as nested containers keyed by index.
  • New @TLVCodable macro (TLVCodingMacros target) generates CodingKeys, init?(tlvData:), and tlvData; a hand-written CodingKeys enum with explicit type codes is respected. Conformances can also be written by hand (required under Embedded Swift).
  • Minimal Data shim for platforms without Foundation; UUID and Date conformances gated on Foundation availability.
  • Package manifest updated to Swift tools 6.0, with swift-syntax gated behind the SWIFTPM_ENABLE_MACROS environment variable.
  • Tests rewritten against the new API, preserving the previous byte-exact wire format vectors, plus macro expansion tests.
  • CI updated with an Embedded Swift job:
SWIFTPM_ENABLE_MACROS=0 swift build --target TLVCoding \
    --triple armv7em-none-none-eabi \
    -Xswiftc -enable-experimental-feature -Xswiftc Embedded \
    -Xswiftc -wmo

Breaking changes

  • TLVEncoder, TLVDecoder, formatting options (TLVDateFormatting, TLVUUIDFormatting, TLVNumericFormatting, TLVOutputFormatting), and dictionary support are removed.
  • Encoding is fixed to the previous defaults: little-endian, UUID as 16 bytes, Date as seconds since 1970.

@colemancda
colemancda merged commit 7bf684c into master Jul 18, 2026
8 of 10 checks passed
@colemancda colemancda mentioned this pull request Jul 18, 2026
4 tasks
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