http://stackoverflow.com/questions/10277576/google-protocol-buffers-on-iosjava
http://stackoverflow.com/questions/8759202/google-protocol-buffers-on-ios-objective-cios
#### build 2.4.1 failed on mac os x 10.9c++
I think the right way to fix it is to modify the message.h like below #ifdef __DECCXX // HP C++'s iosfwd doesn't work. #include <iostream> #else #include <sstream> //#include <iosfwd> #endif
Adding #include <istream> to src/google/protobuf/message.cc fixes this problem, as per the latest version of that file in svn.
加入 proto文件自動編譯objective-c
In "Using:", choose "custom script" and use a script like this:macos
protoc --plugin=/usr/local/bin/protoc-gen-objc $INPUT_FILE_PATH --objc_out=$DERIVED_FILES_DIR
app
In Output files, add the generated files (there should be two files, $(INPUT_FILE_BASE).pb.m
and $(INPUT_FILE_BASE).pb.h
.ide
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)svn
You should be able to compile without any linking error. To give you an idea this is what I directly compileui
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 likethis
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 =newPacket;[data getBytes:raw length:[data length]]; p->ParseFromArray(raw,[data length]);return p;}