Norio Nomura and I (ok, honestly mostly Norio 😅) have been building a Swift library for encoding & decoding YAML for the last 18 months and it’s now stable enough to make a 1.0 release and share with the world.
You could say it’s a Swift binding for LibYAML but I’d argue it’s much more than that.
I’m actually very happy with how this library ended up. It plays nicely with Swift 4’s Codable protocol, meaning that you get fast & type-safe encoding & decoding that feels right at home in modern Swift.
Here’s a simple example of encoding & decoding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Alternatively, you can use it to work with Swift scalar & collection types, which is probably the easiest way to start parsing arbitrary YAML for your projects. Finally, there’s a third mode, which is a Yams-native API that best translates to how LibYAML works.
This library’s been powering a number of popular projects that use YAML for configuration, like SwiftLint, SwiftGen, XcodeGen & used in SourceKitten to parse Swift Package Manager build manifests. So if you’ve wanted to add YAML configuration files to your Swift CLI, or want to interoperate with other tools that process YAML, I encourage you to give Yams a try.