{"id":32150369,"url":"https://github.com/truewebber/swift-protoreflect","last_synced_at":"2026-04-02T16:59:37.241Z","repository":{"id":281529288,"uuid":"875409929","full_name":"truewebber/swift-protoreflect","owner":"truewebber","description":"SwiftProtoReflect is a dynamic Protocol Buffers library for Swift, enabling reflection-based message handling, serialization, and deserialization without the need for precompiled .proto files.","archived":false,"fork":false,"pushed_at":"2026-03-28T18:55:48.000Z","size":2041,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-28T21:09:46.749Z","etag":null,"topics":["data-structures","protobuf","protocol-buffers","reflection","serialization","serialization-deserialization","swift","swift-library"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/truewebber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-19T22:33:27.000Z","updated_at":"2026-03-28T18:55:52.000Z","dependencies_parsed_at":"2025-06-08T02:40:22.857Z","dependency_job_id":"7ae3886c-c6e6-4487-9a7d-9237b8f820eb","html_url":"https://github.com/truewebber/swift-protoreflect","commit_stats":null,"previous_names":["truewebber/swift-protoreflect"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/truewebber/swift-protoreflect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truewebber%2Fswift-protoreflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truewebber%2Fswift-protoreflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truewebber%2Fswift-protoreflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truewebber%2Fswift-protoreflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/truewebber","download_url":"https://codeload.github.com/truewebber/swift-protoreflect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truewebber%2Fswift-protoreflect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31310980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","protobuf","protocol-buffers","reflection","serialization","serialization-deserialization","swift","swift-library"],"created_at":"2025-10-21T10:01:22.079Z","updated_at":"2026-04-02T16:59:37.236Z","avatar_url":"https://github.com/truewebber.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftProtoReflect\n\nA Swift library for dynamic Protocol Buffers message manipulation without pre-compiled schemas.\n\n[![Platform](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ftruewebber%2Fswift-protoreflect%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/truewebber/swift-protoreflect)\n[![Swift Package Index](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ftruewebber%2Fswift-protoreflect%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/truewebber/swift-protoreflect)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](LICENSE)\n[![Coverage](https://img.shields.io/badge/line%20coverage-93.4%25-green.svg?style=flat)](#quality-metrics)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/truewebber/swift-protoreflect)\n\n## Overview\n\nSwiftProtoReflect enables runtime manipulation of Protocol Buffers messages without requiring code generation from `.proto` files. This is useful for building generic tools, API gateways, data processors, and other applications that need to work with protobuf schemas dynamically.\n\n## Installation\n\nAdd to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/truewebber/swift-protoreflect.git\", from: \"5.0.0\")\n]\n```\n\n\u003e **Note:** If you are upgrading from 4.x, see the [Migration Guide](MIGRATION_GUIDE.md) for details on breaking changes.\n\n## Basic Usage\n\n### Creating Messages Dynamically\n\n```swift\nimport SwiftProtoReflect\n\n// Define a message schema at runtime\nlet personSchema = try MessageDescriptor.builder(\"Person\")\n    .addField(\"name\", number: 1, type: .string)\n    .addField(\"age\", number: 2, type: .int32)\n    .addField(\"emails\", number: 3, type: .string, label: .repeated)\n    .build()\n\n// Create and populate a message\nlet message = try MessageFactory().createMessage(from: personSchema)\ntry message.set(\"name\", value: \"Alice\")\ntry message.set(\"age\", value: 25)\ntry message.set(\"emails\", value: [\"alice@example.com\"])\n\n// Serialize to binary or JSON\nlet binaryData = try BinarySerializer().serialize(message: message)\nlet jsonString = try JSONSerializer().serialize(message: message)\n```\n\n### Working with Well-Known Types\n\n```swift\n// Timestamps\nlet timestampMessage = try DynamicMessage.timestampMessage(from: Date())\nlet backToDate = try timestampMessage.toDate()\n\n// JSON-like structures\nlet data: [String: Any] = [\"user\": \"john\", \"active\": true]\nlet structMessage = try DynamicMessage.structMessage(from: data)\n\n// Type erasure\nlet anyMessage = try message.packIntoAny()\nlet unpackedMessage = try anyMessage.unpackFromAny(to: personSchema)\n```\n\n## Features\n\n- **Dynamic Message Creation**: Create and manipulate protobuf messages at runtime\n- **Schema Definition**: Build message descriptors programmatically\n- **Proto3 Compliance**: Syntax tracking, zero defaults, optional presence, enum validation, unknown fields preservation\n- **Canonical JSON**: int64/uint64 as strings, bytes as base64, enums as names, `includeDefaultValues`\n- **Nested Messages**: Recursive binary serialization/deserialization with type resolution\n- **Schema Evolution**: Safe field addition/removal/renaming with unknown field round-trip\n- **Typed Options**: `DescriptorOption` enum for type-safe, `Sendable` descriptor options\n- **Oneof Support**: First-class `OneofDescriptor` with full bridge round-trip\n- **Serialization**: Binary and JSON serialization/deserialization\n- **Well-Known Types**: 18 types — Timestamp, Duration, Empty, FieldMask, Struct, Value, Any, ListValue, NullValue, and 9 wrapper types\n- **Swift Protobuf Compatibility**: Convert between static and dynamic messages, Visitor-based descriptor extraction\n- **Type Registry**: Centralized type management and lookup\n- **Swift 6 Ready**: All public types conform to `Sendable`\n\n## Examples\n\nThe library includes 47 working examples demonstrating various use cases:\n\n```bash\ngit clone https://github.com/truewebber/swift-protoreflect.git\ncd swift-protoreflect/examples\n\n# Basic examples\nswift run HelloWorld\nswift run FieldTypes\nswift run TimestampDemo\n\n# Proto3 compliance\nswift run SyntaxAndDefaults\nswift run OptionalPresence\nswift run UnknownFields\nswift run JsonCanonical\n\n# Advanced examples\nswift run ApiGateway\nswift run MessageTransform\n```\n\nExamples are organized by topic:\n- **Basic Usage** (4): Getting started\n- **Dynamic Messages** (7): Message manipulation\n- **Serialization** (5): Binary and JSON formats\n- **Registry** (4): Type management\n- **Well-Known Types** (10): Google standard types, wrapper types, ListValue\n- **Advanced** (6): Complex patterns\n- **Real-World** (5): Production scenarios\n- **Proto3 Compliance** (6): Syntax, optional presence, unknown fields, canonical JSON, schema evolution, nested messages\n\n## Requirements\n\n- Swift 5.9+\n- macOS 12.0+ / iOS 15.0+\n- **Recommended:** SwiftProtoReflect 5.0.0+\n\n## Dependencies\n\n- [SwiftProtobuf](https://github.com/apple/swift-protobuf) 1.29.0+\n\n## Documentation\n\n- **[Architecture Guide](docs/ARCHITECTURE.md)**: Technical implementation details\n- **[Migration Guide](MIGRATION_GUIDE.md)**: Migrating from static Swift Protobuf\n\n## Use Cases\n\n- Generic protobuf tools (viewers, debuggers, converters)\n- API gateways with dynamic message routing\n- Data processing pipelines with runtime schema handling\n- Testing tools that generate data for arbitrary schemas\n- Configuration systems using protobuf schemas\n\n## Integration with Swift Protobuf\n\nSwiftProtoReflect works alongside existing Swift Protobuf code:\n\n```swift\n// Convert static to dynamic\nlet staticMessage = Person.with { /* ... */ }\nlet dynamicMessage = try staticMessage.toDynamicMessage()\n\n// Convert dynamic to static\nlet staticMessage: Person = try dynamicMessage.toStaticMessage()\n```\n\n## Testing\n\nThe library has comprehensive test coverage covering all functionality and edge cases.\n\n### Quality metrics\n\nCode coverage is measured with LLVM (`make coverage` after `make test`) over `Sources/SwiftProtoReflect/`:\n\n| Metric | Coverage |\n|--------|----------|\n| Lines | **93.37%** |\n| Regions | **95.69%** |\n| Functions | **95.52%** |\n\nFigures reflect the current test suite; re-run `make test` and `make coverage` locally for up-to-date numbers.\n\n## License\n\nMIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewebber%2Fswift-protoreflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruewebber%2Fswift-protoreflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewebber%2Fswift-protoreflect/lists"}