Using Protocol Buffers with Objective-C

2019-02-02 14:16发布

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.

5条回答
Juvenile、少年°
2楼-- · 2019-02-02 14:31

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.)

查看更多
Animai°情兽
3楼-- · 2019-02-02 14:36

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.

查看更多
淡お忘
4楼-- · 2019-02-02 14:36

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

I did try the objc PB version but without success.

查看更多
做自己的国王
5楼-- · 2019-02-02 14:44

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?

查看更多
我只想做你的唯一
6楼-- · 2019-02-02 14:46

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 
查看更多
登录 后发表回答