keyPathString macro allows you to generate a property name string value of a key path expression.
- Click File > Add Package Dependencies
- Paste the following link into the search field on the upper-right:
https://github.com/Jaesung-Jung/KeyPathStringMacro.git
In Package.swift:
dependencies: [
.package(url: "https://github.com/Jaesung-Jung/KeyPathStringMacro.git", from: "0.1.0")
]And then add the dependency to your targets.
let keyPathString = #keyPathString(\User.name) // "name"MIT license. See LICENSE for details.