Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Oct 10, 2024
1 parent ba06683 commit aa82d82
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
# ProtobufKit

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FProtobufKit%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/ProtobufKit) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FProtobufKit%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/ProtobufKit)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FProtobufKit%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/ProtobufKit) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FProtobufKit%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/ProtobufKit) [![codecov](https://codecov.io/gh/OpenSwiftUIProject/ProtobufKit/graph/badge.svg?token=VDKQVOP20I)](https://codecov.io/gh/OpenSwiftUIProject/ProtobufKit)

ProtobufKit is a lightweight Swift library for working with Protocol Buffers.
ProtobufKit is a lightweight[^1] replacement of [swift-protobuf](https://github.com/apple/swift-protobuf) for working with Protocol Buffers in Swift.

It is cross-platform and compatible with SwiftUI's internal Protobuf implementation.
## Overview

## Getting Started Using ProtobufMessage
ProtobufKit is cross-platform Swift package on Darwin platform (without OS version limitation) and Linux.[^2]

In your `Package.swift` Swift Package Manager manifest, add the following dependency to your `dependencies` argument:
| **Workflow** | **CI Status** |
|-|:-|
| **Compatibility Test** | [![Compatibility tests](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/compatibility_tests.yml) |
| **macOS Unit Test** | [![macOS](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/macos.yml) |
| **iOS Unit Test** | [![iOS](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ios.yml) |
| **Ubuntu 22.04 Unit Test** | [![Ubuntu](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ubuntu.yml) |

ProtobufKit is compatible with SwiftUI's internal Protobuf implementation so that you can use it to decode some internal binary data of SwiftUI (eg. ArchivedView).

The core design of ProtobufKit is `ProtobufMessage` which is similar to `Codable` and easy to customize.

```swift
public protocol ProtobufEncodableMessage {
func encode(to encoder: inout ProtobufEncoder) throws
}
public protocol ProtobufDecodableMessage {
init(from decoder: inout ProtobufDecoder) throws
}

public typealias ProtobufMessage = ProtobufDecodableMessage & ProtobufEncodableMessage
```

You can also use it with Codable by conforming your message type to `CodaleByProtobuf` or annoate your message instance with `ProtobufCodable` propertyWrapper.

## Getting Started

In your `Package.swift` file, add the following dependency to your `dependencies` argument:

```swift
.package(url: "https://github.com/OpenSwiftUIProject/ProtobufKit.git", from: "0.1.0"),
```

Add the dependency to any targets you've declared in your manifest:
Then add the dependency to any targets you've declared in your manifest:

```swift
.target(
Expand Down Expand Up @@ -54,17 +80,9 @@ struct SimpleMessage: ProtobufMessage {
Please see ProtobufKit [documentation site](https://swiftpackageindex.com/OpenSwiftUIProject/ProtobufKit/main/documentation/protobufkit)
for more detailed information about the library.

## Supported platforms

The table below describes the current level of support that `ProtobufKit` has
for various platforms:
## Future work

| **Workflow** | **CI Status** |
|-|:-|
| **Compatibility Test** | [![Compatibility tests](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/compatibility_tests.yml) |
| **macOS Unit Test** | [![macOS](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/macos.yml) |
| **iOS Unit Test** | [![iOS](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ios.yml) |
| **Ubuntu 22.04 Unit Test** | [![Ubuntu](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/ProtobufKit/actions/workflows/ubuntu.yml) |
ProtobufKit does not have compiler build-in support like Codable`'s `Codable` protocol, so you have to write the encode and decode logic by yourself. This can be improved by future macro API support.

## License

Expand All @@ -83,3 +101,6 @@ See LICENSE file - MIT
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=OpenSwiftUIProject/ProtobufKit&type=Date" />
</picture>
</a>

[^1]: Under macOS + Build for profiling option, ProtobufKit's ProtobufKit.o is 142KB while [swift-protobuf](https://github.com/apple/swift-protobuf)'s SwiftProtobuf.o is 5.7MB
[^2]: WASI support will be added in the future

0 comments on commit aa82d82

Please sign in to comment.