> Is there any direct support for Protocol Buffers  in iOS? (armv6,
> armv7)
> I have gone through he following 
> link..http://code.google.com/p/metasyntactic/wiki/ProtocolBuffers
> It uses v2.2 and currently available version is v2.4

I use latest version in my app .. you don't really need objc direct
support if you are familiar with C++, there is only one point where
you have to pass from std::string to NSData and viceversa. And its
pretty simple.

To compile and test the easiest way Ive found is to just import the
whole google directory in my own project :) (the second time you can
make your own framework but for testing this procedure just works)

- download latest version
- autogen configure and make like you were just building for macosx
(you need command line tools) . This way you end up with protoc binary
and the library for macosx (which you don't need)
- open your Xcode iOS project
- add "new file" to your project and select google directory
- add the directory of google headers to your additional include
- add config.h from the protobuffer src directory to your app
- from the google group remove everything that contains unitest :)
- from the google group remove compiler and java stuff;
- you should be able to compile without any linking error

to give you an idea this is what I directly compile

Then you can use protoc to generate c++ source files for your
protocol. To use them with objc you have to rename your source to
file  "mm" then you can do something like


let's say your message is called Packet

- (NSData *)getDataForPacket:(Packet *)packet {
    std::string ps = packet->SerializeAsString();
    return [NSData dataWithBytes:ps.c_str() length:ps.size()];


- (Packet *)getPacketFromNSData:(NSData *)data {
  char raw[[data length]];
  Packet *p = new Packet;
  [data getBytes:raw length:[data length]];
  p->ParseFromArray(raw, [data length]);
  return p;

this should give you a good start :)

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to