在 Objective-C 中使用 Protocol Buffer

发布于 2024-08-08 09:45:47 字数 254 浏览 5 评论 0原文

有人在使用 Objective-C 开发应用程序时使用过 Google 的 Protocol Buffers 吗?

当前是否有任何将 .proto 文件编译为 Objective-C 的项目,所有 Google 文档都只是引用 Java、C++ 或 Python。

Has anyone used Google's Protocol Buffers when developing applications in Objective-C?

Are there any current projects for compiling .proto files into Objective-C, all the Google docs simply refer to Java, C++ or Python.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

请远离我 2024-08-15 09:45:47

我一直在研究 Cyrus 项目的一个分支。它基于 protobuf 2.3,作为 protoc 插件 (protoc-gen-objc) 工作,而不需要修改 protobuf 发行版。

您可以在 GitHub 上找到它作为 protobuf-obj 项目。

I've been working on an fork of Cyrus' project. It's based on protobuf 2.3 and works as a protoc plugin (protoc-gen-objc) instead of requiring a modified protobuf distribution.

You can find it as the protobuf-obj project on GitHub.

海拔太高太耀眼 2024-08-15 09:45:47

第三方页面列出了此 Objective-C 端口。不幸的是,该项目目前似乎是空的,但无论如何看到它还是令人鼓舞的。我听说过该项目的内部传闻,但在今天之前并没有将其视为开源项目。

不过,您可以联系项目所有者 (Cyrus Najmabadi) 询问相关情况...

(一个小细节 - Cyrus 在加入 Google 之前曾在 Microsoft 的 C# 团队工作。)

The Third Party page lists this Objective-C port. Unfortunately the project appears to be empty at the moment, but it's encouraging to see it anyway. I had heard internal rumours of the project, but hadn't seen it as an open source project before today.

You could get in touch with the project owner (Cyrus Najmabadi) to ask about it though...

(Small piece of trivia - Cyrus used to work on the C# team in Microsoft before he joined Google.)

厌味 2024-08-15 09:45:47

这可能有帮助,也可能没有帮助,但 Apache Thrift(最初由 Facebook 开发)支持 Cocoa,并且似乎有人尝试在 iPhone 中使用它。

Thrift 官方支持更多语言。但 Protocol Buffers 的兴趣是 Stack Overflow 的 5 倍,所以谁知道它在维护方面是否是一个很好的替代品,更不用说与您自己的项目的兼容性了!不过,也许还是值得考虑的。

我刚刚问了一个相关问题,如果得到好的答案,您可能会发现有帮助: 任何成功在 iPhone 上使用 Apache Thrift?

This may or may not be helpful, but Apache Thrift (originally developed at Facebook) supports Cocoa, and seems to have people attempting to use it in the iPhone.

Thrift officially supports more languages. But Protocol Buffers have 5x the Stack Overflow interest, so who knows if it's a good replacement in terms of maintenance—not to mention compatibility with your own project! Still, maybe it's worth consideration.

I just asked a related question you may find helpful if it gets good answers: Any success using Apache Thrift on iPhone?

雾里花 2024-08-15 09:45:47

Protocol Buffers v3 支持 Objective-C

Protocol Buffers v3 支持 Objective-C 作为一流的语言。

要从 .proto 文件生成 Objective-C 代码,请使用 objc_out 选项调用编译器:

 protoc --proto_path=src --objc_out=build/gen src/foo.proto src/bar/baz.proto 

Protocol Buffers v3 supports Objective-C

Protocol Buffers v3 supports Objective-C as a first class language.

To generate Objective-C code from a .proto file call the compiler with the objc_out option:

 protoc --proto_path=src --objc_out=build/gen src/foo.proto src/bar/baz.proto 
°如果伤别离去 2024-08-15 09:45:47

我更喜欢在 objc 项目中使用 C++ 生成的类,效果很好。

我确实尝试过 objc PB 版本但没有成功。

I prefer to use c++ generated classes within my objc projects, works just fine.

I did try the objc PB version but without success.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文