About ProtocolBuffers on iPhone

hi i am a chinese iOS Engineer.

and i am trying to run protocol buffers on iphone, and i download the metasyntactic project from google code, and do follow your introduction.

But when i type the protoc command in my Terminal i got a error, such as:

My command: > protoc --proto_path=proto/src --objc_out=proto/build proto/src/common.proto

and the error message is :protoc-gen-objc: program not found or is not executable --objc_out: protoc-gen-objc: Plugin failed with status code 1.

and then a got a project from google code and compile a protoc-gen-objc and i run the protoc like this: protoc protoc-gen-objc --proto_path=geo3 --proto_path=src --objc_out=build/gen src/geo3.proto

and finally i got this error message:

protoc-gen-objc: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (eg absolute and relative) are equivalent (it's harder than you think).

so how should i fix it , and get the .pb.m file

Thank you very much.


Seems it's long time for this thread, I got the same problem when use the package from here https://github.com/booyah/protobuf-objc.

after install official protobuf package from google and make the booyah's package ready, you should manually export the path for the protoc-gen-objc, for me it's located in /your install path/src/compiler/, then call the protoc command to generate the .h and .m for you.

if this is the same case as you, it's works. hope it will help on you and others.


I encountered the same problem. The reason I got the message was because I was using the C++ protoc executable. You must have make the protobuf from the official google site. Go to your objective-c port directory where the protoc resides and do this:

./protoc --proto_path=proto/src --objc_out=proto/build proto/src/common.proto

This will make sure that you use objective-c protoc in your current directory.

链接地址: http://www.djcxy.com/p/64784.html

上一篇: dt与protoc不工作

下一篇: 关于iPhone上的ProtocolBuffers