Skip to content

elf0-fr/ETBCodable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ETBCodable

Declarative Codable conformance with Swift Macros

Overview

ETBCodable is a Swift Package that provides two Swift macros — @Codable and @CodingKey — to eliminate boilerplate when conforming your models to Codable. The macros generate a CodingKeys enum for your stored properties and attach Codable conformance, allowing the compiler to synthesize init(from:) and encode(to:) automatically.

  • Zero runtime overhead: All code is generated at compile time.
  • Non-invasive: If your type already conforms to Codable or defines CodingKeys, the macro does nothing.
  • Fine-grained control: Override individual keys with @CodingKey("custom_key").
  • Safe defaults: Computed and static properties are ignored.

Requirements

  • Swift 6.2 or later (the package uses swift-tools-version: 6.2)
  • Platforms:
    • macOS 10.15+
    • iOS 13+
    • tvOS 13+
    • watchOS 6+
    • macCatalyst 13+

Installation

Xcode

  1. In Xcode, go to File > Add Package Dependencies…
  2. Enter the repository URL for this package: https://github.com/elf0-fr/ETBCodable.git.
  3. Add the ETBCodable product to your target.

Swift Package Manager (Package.swift)

Add the package to your dependencies and link the ETBCodable product to your target:

// In your Package.swift
.dependencies: [
    .package(url: "https://github.com/elf0-fr/ETBCodable.git", from: "1.0.0")
],
.targets: [
    .target(
        name: "YourTarget",
        dependencies: [
            .product(name: "ETBCodable", package: "ETBCodable")
        ]
    )
]

About

Codable tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages