[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6849":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":16,"starSnapshotCount":16,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},6849,"swift-protobuf","apple\u002Fswift-protobuf","apple","Plugin and runtime library for using protobuf with Swift","",null,"Swift",4929,527,99,57,0,1,5,12,65.87,"Apache License 2.0",false,"main",[],"2026-06-12 04:00:30","\u003Cimg src=\"https:\u002F\u002Fswift.org\u002Fassets\u002Fimages\u002Fswift.svg\" alt=\"Swift logo\" height=\"70\" >\n\n# Swift Protobuf\n\n**Welcome to Swift Protobuf!**\n\n[Apple's Swift programming language](https:\u002F\u002Fswift.org\u002F) is a perfect\ncomplement to [Google's Protocol Buffer](https:\u002F\u002Fprotobuf.dev\u002F)\n(\"protobuf\") serialization technology.\nThey both emphasize high performance and programmer safety.\n\nThis project provides both the command-line program that adds Swift\ncode generation to Google's `protoc` and the runtime library that is\nnecessary for using the generated code.\nAfter using the protoc plugin to generate Swift code from your .proto\nfiles, you will need to add this library to your project.\n\n[![Build and Test](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fbuild.yml)\n[![Check Upstream Protos](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fcheck_upstream_protos.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fcheck_upstream_protos.yml)\n[![Run Protobuf Head Conformance Tests](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fhead_conformance.yml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf\u002Factions\u002Fworkflows\u002Fhead_conformance.yml)\n\n# Features of SwiftProtobuf\n\nSwiftProtobuf offers many advantages over alternative serialization\nsystems:\n\n* Safety: The protobuf code-generation system avoids the\n  errors that are common with hand-built serialization code.\n* Correctness: SwiftProtobuf passes both its own extensive\n  test suite and Google's full conformance test for protobuf\n  correctness.\n* Schema-driven: Defining your data structures in a separate\n  `.proto` schema file clearly documents your communications\n  conventions.\n* Idiomatic: SwiftProtobuf takes full advantage of the Swift language.\n  In particular, all generated types provide full Swift copy-on-write\n  value semantics.\n* Efficient binary serialization: The `.serializedBytes()`\n  method returns a bag of bytes with a compact binary form of your data.\n  You can deserialize the data using the `init(contiguousBytes:)`\n  initializer.\n* Standard JSON serialization: The `.jsonUTF8Bytes()` method returns a JSON\n  form of your data that can be parsed with the `init(jsonUTF8Bytes:)`\n  initializer.\n* Hashable, Equatable: The generated struct can be put into a\n  `Set\u003C>` or `Dictionary\u003C>`.\n* Performant: The binary and JSON serializers have been\n  extensively optimized.\n* Extensible: You can add your own Swift extensions to any\n  of the generated types.\n\nBest of all, you can take the same `.proto` file and generate\nJava, C++, Python, or Objective-C for use on other platforms. The\ngenerated code for those languages will use the exact same\nserialization and deserialization conventions as SwiftProtobuf, making\nit easy to exchange serialized data in binary or JSON forms, with no\nadditional effort on your part.\n\n# Documentation\n\nMore information is available in the associated documentation:\n\n * [Google's protobuf documentation](https:\u002F\u002Fprotobuf.dev\u002F)\n   provides general information about protocol buffers, the protoc compiler,\n   and how to use protocol buffers with C++, Java, and other languages.\n * [PLUGIN.md](Documentation\u002FPLUGIN.md) documents the `protoc-gen-swift`\n   plugin that adds Swift support to the `protoc` program\n * [API.md](Documentation\u002FAPI.md) documents how to use the generated code.\n   This is recommended reading for anyone using SwiftProtobuf in their\n   project.\n * [INTERNALS.md](Documentation\u002FINTERNALS.md) documents the internal structure\n   of the generated code and the library.  This\n   should only be needed by folks interested in working on SwiftProtobuf\n   itself.\n * [STYLE_GUIDELINES.md](Documentation\u002FSTYLE_GUIDELINES.md) documents the style\n   guidelines we have adopted in our codebase if you are interested in\n   contributing\n\n# Getting Started\n\nIf you've worked with Protocol Buffers before, adding Swift support is very\nsimple: you just need to build the `protoc-gen-swift` program and copy it into\nyour PATH.\nThe `protoc` program will find and use it automatically, allowing you\nto build Swift sources for your proto files.\nYou will also, of course, need to add the SwiftProtobuf runtime library to\nyour project as explained below.\n\n## System Requirements\n\nTo use Swift with Protocol buffers, you'll need:\n\n* A Swift 6.0 or later compiler (or, if building with Xcode, Xcode 16.0 or later\n  as required by the App Store). The Swift protobuf project is being developed\n  and tested against the latest release version of Swift available from\n  [Swift.org](https:\u002F\u002Fswift.org)\n\n* Google's protoc compiler.  The Swift protoc plugin is being actively developed\n  and tested against the latest protobuf sources. The SwiftProtobuf tests need a\n  version of protoc which supports the `swift_prefix` option (introduced in\n  protoc 3.2.0). It may work with earlier versions of protoc. You can get recent\n  versions from\n  [Google's github repository](https:\u002F\u002Fgithub.com\u002Fprotocolbuffers\u002Fprotobuf).\n\n## Building and Installing the Code Generator Plugin\n\nTo translate `.proto` files into Swift, you will need both Google's\nprotoc compiler and the SwiftProtobuf code generator plugin.\n\nBuilding the plugin should be simple on any supported Swift platform:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf.git\ncd swift-protobuf\n```\n\nPick what released version of SwiftProtobuf you are going to use.  You can get\na list of tags with:\n\n```bash\ngit tag -l\n```\n\nOnce you pick the version you will use, set your local state to match, and\nbuild the protoc plugin:\n\n```bash\ngit checkout tags\u002F[tag_name]\nswift build -c release\n```\n\nThis will create a binary called `protoc-gen-swift` in the `.build\u002Frelease`\ndirectory.\n\nTo install, just copy this one executable into a directory that is\npart of your `PATH` environment variable.\n\nNOTE: The Swift runtime support is now included with macOS. If you are\nusing old Xcode versions or are on older system versions, you might need\nto use also use `--static-swift-stdlib` with `swift build`.\n\n### Alternatively install via Homebrew\n\nIf you prefer using [Homebrew](https:\u002F\u002Fbrew.sh):\n\n```bash\nbrew install swift-protobuf\n```\n\nThis will install `protoc` compiler and Swift code generator plugin.\n\n## Converting .proto files into Swift\n\nTo generate Swift output for your .proto files, you run the `protoc` command as\nusual, using the `--swift_out=\u003Cdirectory>` option:\n\n```bash\nprotoc --swift_out=. my.proto\n```\n\nThe `protoc` program will automatically look for `protoc-gen-swift` in your\n`PATH` and use it.\n\nEach `.proto` input file will get translated to a corresponding `.pb.swift`\nfile in the output directory.\n\nMore information about building and using `protoc-gen-swift` can be found\nin the [detailed Plugin documentation](Documentation\u002FPLUGIN.md).\n\n## Adding the SwiftProtobuf library to your project...\n\nTo use the generated code, you need to include the `SwiftProtobuf` library\nmodule in your project.  How you do this will vary depending on how\nyou're building your project.  Note that in all cases, we strongly recommend\nthat you use the version of the SwiftProtobuf library that corresponds to\nthe version of `protoc-gen-swift` you used to generate the code.\n\n### ...using `swift build`\n\nAfter copying the `.pb.swift` files into your project, you will need to add the\n[SwiftProtobuf library](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf) to your\nproject to support the generated code.\nIf you are using the Swift Package Manager, add a dependency to your\n`Package.swift` file and import the `SwiftProtobuf` library into the desired\ntargets.  Adjust the `\"1.27.0\"` here to match the `[tag_name]` you used to build\nthe plugin above:\n\n```swift\ndependencies: [\n    .package(url: \"https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-protobuf.git\", from: \"1.27.0\"),\n],\ntargets: [\n    .target(\n      name: \"MyTarget\",\n      dependencies: [.product(name: \"SwiftProtobuf\", package: \"swift-protobuf\")]\n    ),\n]\n```\n\n### ...using Xcode\n\nIf you are using Xcode, then you should:\n\n* Add the `.pb.swift` source files generated from your protos directly to your\n  project\n* Add this SwiftPM package as dependency of your xcode project:\n  [Apple Docs](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Fswift_packages\u002Fadding_package_dependencies_to_your_app)\n\n### ...using CocoaPods\n\nIf you're using CocoaPods, add this to your `Podfile` adjusting the `:tag` to\nmatch the `[tag_name]` you used to build the plugin above:\n\n```ruby\npod 'SwiftProtobuf', '~> 1.0'\n```\n\nAnd run `pod install`.\n\nNOTE: CocoaPods 1.7 or newer is required.\n\n# Quick Start\n\nOnce you have installed the code generator, used it to\ngenerate Swift code from your `.proto` file, and\nadded the SwiftProtobuf library to your project, you can\njust use the generated types as you would any other Swift\nstruct.\n\nFor example, you might start with the following very simple\nproto file:\n```protobuf\nsyntax = \"proto3\";\n\nmessage BookInfo {\n   int64 id = 1;\n   string title = 2;\n   string author = 3;\n}\n```\n\nThen generate Swift code using:\n```bash\nprotoc --swift_out=. DataModel.proto\n```\n\nThe generated code will expose a Swift property for\neach of the proto fields as well as a selection\nof serialization and deserialization capabilities:\n```swift\n\u002F\u002F Create a BookInfo object and populate it:\nvar info = BookInfo()\ninfo.id = 1734\ninfo.title = \"Really Interesting Book\"\ninfo.author = \"Jane Smith\"\n\n\u002F\u002F As above, but generating a read-only value:\nlet info2 = BookInfo.with {\n    $0.id = 1735\n    $0.title = \"Even More Interesting\"\n    $0.author = \"Jane Q. Smith\"\n  }\n\n\u002F\u002F Serialize to binary protobuf format: you can choose to serialize into\n\u002F\u002F any type conforming to `SwiftProtobufContiguousBytes`. For example:\n\u002F\u002F Resolve the `SwiftProtobufContiguousBytes` return value to `Data`\nlet binaryData: Data = try info.serializedBytes()\n\u002F\u002F Resolve the `SwiftProtobufContiguousBytes` return value to `[UInt8]`\nlet binaryDataAsBytes: [UInt8] = try info.serializedBytes()\n\n\u002F\u002F Note that while the `serializedBytes()` spelling is generally preferred,\n\u002F\u002F you may also use `serializedData()` to get the bytes as an instance of\n\u002F\u002F `Data` where required.\n\u002F\u002F This means that the following two statements are equivalent:\n\u002F\u002F let binaryData: Data = try info.serializedBytes()\n\u002F\u002F let binaryData: Data = try info.serializedData()\n\n\u002F\u002F Deserialize a received Data object from `binaryData`\nlet decodedInfo = try BookInfo(serializedData: binaryData)\n\n\u002F\u002F Deserialize a received [UInt8] object from `binaryDataAsBytes`\nlet decodedInfo = try BookInfo(serializedBytes: binaryDataAsBytes)\n\n\u002F\u002F Serialize to JSON format as a Data object, or as any other type conforming to\n\u002F\u002F SwiftProtobufContiguousBytes. For example:\nlet jsonData: Data = try info.jsonUTF8Data()\nlet jsonBytes: [UInt8] = try info.jsonUTF8Bytes()\n\n\u002F\u002F Deserialize from JSON format from `jsonBytes`\nlet receivedFromJSON = try BookInfo(jsonUTF8Bytes: jsonBytes)\n```\n\nYou can find more information in the detailed\n[API Documentation](Documentation\u002FAPI.md).\n\n## Report any issues\n\nIf you run into problems, please send us a detailed report.\nAt a minimum, please include:\n\n* The specific operating system and version (for example, \"macOS 10.12.1\" or\n  \"Ubuntu 16.10\")\n* The version of Swift you have installed (from `swift --version`)\n* The version of the protoc compiler you are working with from\n  `protoc --version`\n* The specific version of this source code (you can use `git log -1` to get the\n  latest commit ID)\n* Any local changes you may have\n","Swift-protobuf 是一个用于在 Swift 项目中使用 Protocol Buffers 的插件和运行时库。它提供了与 Google 的 `protoc` 集成的命令行工具来生成 Swift 代码，以及必要的运行时支持库。该项目的核心功能包括安全、正确的数据序列化与反序列化，支持二进制和 JSON 格式，并且所有生成的类型都遵循 Swift 的值语义。此外，Swift-protobuf 保证了跨语言的一致性，使得同一 `.proto` 文件可以在不同平台上生成 Java、C++、Python 或 Objective-C 代码，从而方便地进行数据交换。此工具非常适合需要高效、可靠的数据通信或存储的场景，尤其是在多平台开发环境中。",2,"2026-06-11 03:09:13","top_language"]