avro-swift is a native Swift library build to serialize and deserialize Apache Avro™ data.
Example:
import Avro
@AvroSchema
struct User: Codable {
let name: String
let age: Int
@LogicalType(.date) let dob: Date
let username: String
let address: Address
}
@AvroSchema
struct Address: Codable {
let street: String
}
let user = User(name: "John Doe", age: 22, dob: Date(), username: "johndoe", address: Address(street: "John Doe Street"))
let decodedAvro = try AvroEncoder(schema: User.avroSchema).encode(user)
let roundTrip = try AvroDecoder(schema: User.avroSchema).decode(User.self, from: decodedAvro)The full documentation is provided via DocC on Swift Package Manager.
To integrate avro-swift into your project using Swift Package Manager, follow these steps:
- Open your project in Xcode.
- Select
File>Swift Packages>Add Package Dependency.... - Enter the package repository URL:
https://github.com/flexlixrup/avro-swift. - Choose the latest release or specify a version range.
- Add the package to your target.
Alternatively, you can add the following dependency to your Package.swift file:
dependencies: [
.package(url: "https://github.com/flexlixrup/avro-swift", from: "0.0.1")
]Then, include Pulsar as a dependency in your target:
.target(
name: "YourTargetName",
dependencies: [
"Avro"
]),Warning
This package uses Conventional Commits to detect the semantic versioning. Commits not following this format will not be accepted.
If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.