Skip to content

Releases: EngOmarElsayed/swift-lenient-codable

Release list

v1.0.0

Choose a tag to compare

@EngOmarElsayed EngOmarElsayed released this 20 Jul 09:47
944f4e4

Swift macros for resilient Codable — one unknown enum case or malformed array element no longer fails your whole response. Lenient by default, strict by explicit opt-in, with compile-time diagnostics and fix-its.

Highlights

  • @LenientDecodable generates CodingKeys, init(from:), and the Decodable conformance for a struct, with every stored property lenient by default.
  • @NilOnFailure (the implicit default) — any failure decodes as nil exactly where it broke: whole-value on T?, in-place element padding on [T?] (count and positions preserved), and [T?]? for absent-vs-empty distinction.
  • @DropOnFailure — failed array elements are removed, survivors keep their order. Never applied by default; dropping is an explicit product decision.
  • @Strict — byte-for-byte synthesized decoding, and the only way a decode can fail. grep @Strict audits every hard failure point.
  • Compile-time shape validation — invalid strategy/type combinations are compile errors with fix-its (change 'Int' to 'Int?', add '@Strict', …), so nothing is silently strict and nothing is silently lenient.
  • Debug observability — every absorbed failure (including missing keys) logs via os.Logger (subsystem LenientCodable, category decoding); JSON null is the one intentional silent case. Logging compiles out entirely in release builds.
  • No wrapper types — properties stay plain stored properties, so Equatable/Hashable/memberwise-init synthesis keep working, and the generated code is readable via Expand Macro.

Requirements

  • Swift 6.2+ toolchain (Xcode 26+)
  • iOS 13+, macOS 10.15+, tvOS 13+, watchOS 6+, Mac Catalyst 13+

Installation

dependencies: [
    .package(url: "https://github.com/EngOmarElsayed/swift-lenient-codable.git", from: "1.0.0"),
]

See the README for the full guide.