I recently used protocol buffers to great effect in this particular area. It's got very very little overhead and performs better than the native objective C serialization/deserialization(at least on the ipod touch I'm testing for performance with, since it is the slowest device we want to support).
It took me a while to set them up as a newbie in iOS development though(the python side was really easy though).
This blog post really helps: http://nserror.me/blog/2011/06/03/protocol-buffers-and-xcode/
To summarize on how to integrate protocol buffers into an objective C project -- This took me a whole day to piece together so I'm putting it up in the hope someone in my situation finds it useful:
- get protocol buffers from here
- configure/make/make install
- get this project(that's git clone https://github.com/booyah/protobuf-objc.git for the lazy)
- autogen.sh/configure/make/make install
- In protobuf-objc/src/runtime there is an xcode project. Open it, build and then close xcode again. It is really important you do this.
- open up your project in Xcode. Go to the "build rules" tab in the target. Add a custom build rule for *.proto files.
The script:
/usr/local/bin/protoc --plugin=/usr/local/bin/protoc-gen-objc \
--proto_path=${INPUT_FILE_DIR} \
--objc_out=${DERIVED_SOURCES_DIR} \
${INPUT_FILE_PATH}
The output files:
${DERIVED_SOURCES_DIR}/${INPUT_FILE_BASE}.pb.h
${DERIVED_SOURCES_DIR}/${INPUT_FILE_BASE}.pb.m
- copy the protobuf-objc project into the same directory you have your .xcodeproj in
- Add a reference to the project in protobuf-obj/src/runtime (just drag into from finder into your project
- Under "build phases" for your target add a dependency on ProtocolBuffers
- Under "build settings" select the "all" view and add the following to your header search paths: ${SOURCE_ROOT}/protobuf-objc/src/runtime/Build/Products
- In the summary for your target, add a link to the .a file generated by the ProtocolBuffers project.
- And that's it, from now on, you just add your .proto files to the project(and to the list of files to be compiled) and you can use protocol buffers