What's New

0.1.1

2025-01-28T14:58:36Z

What's Changed

New Contributors

Full Changelog: 0.1.0...0.1.1

Swift Macros

Contains a collection of useful macros for my personal projects.

Usage

Symbol

let symbol = #symbol("swift") // Macro expands to "swift"

In case the provided value is not a valid SF Symbol, Xcode will show a compile error.

URL

let url = #URL("https://www.swift.org") // Macro expands to URL(string: "https://www.swift.org")!

In case the provided value is not a valid URL, Xcode will show a compile error.

AssociatedValues

Add variables to retrieve the associated values.

@AssociatedValues
enum Barcode {
  case upc(Int, Int, Int, Int)
  case qrCode(String)
}

// Expands to
enum Barcode {
  ...

  var upcValue: (Int, Int, Int, Int)? {
    if case let .upc(v0, v1, v2, v3) = self {
        return (v0, v1, v2, v3)
    }
    return nil
  }

  var qrCodeValue: (String)? {
    if case let .qrCode(v0) = self {
        return v0
    }
    return nil
  }
}

Singleton

Generate singleton code for struct and class

@Singleton
struct UserStore {
}

// Expands to
struct UserStore {
  static let shared = UserStore()

  private init() {
  }
}

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Mon May 12 2025 02:38:10 GMT-0900 (Hawaii-Aleutian Daylight Time)