background preloader


Facebook Twitter

Booyah/protobuf-objc. C++ - Google protocol buffers on iOS. Use protobuf on iphone app. This post is a step by step tutorial showing how to use protobuf in iphone application. It shows how to:Create a reusable static libraryCreate a executable projectMix C++ code with object C code1. Start terminal, cd to root folder of protobuf and run . /configure here to generate config.h header file and makefile. 2. Start XCode and create a new project. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. #import "add_personAppDelegate.h" #include "addressbook.pb.h"#include <fstream> using namespace std; @implementation add_personAppDelegate @synthesize window; #pragma mark -#pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { GOOGLE_PROTOBUF_VERIFY_VERSION; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDirectory = [paths objectAtIndex:0]; NSString *filename = [NSString stringWithFormat:@"%@/addressbook.dat", documentDirectory]; @end.

Scala - How Can I Return Protocol Buffers Directly in Play! 2.0 Framework. Jcayzac/play-protobuf. Sbt/sbt-protobuf. Objective c - How can I disable ARC for a single file in a project. Regwez/protobuf-objc-iOS5. ProtocolBuffers - metasyntactic - Objective-C Protocol Buffers for OSX and the iPhone - Cyrus' Playground. Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. For more information see the main page here. This project contains a port of Protocol Buffers that can be used in OSX 10.5 and later and on the iPhone OS 2.0 and later. The port includes a Protocol Buffer compiler (protoc) and a Protocol Buffer static library that you link into any project that you want protobuf support for. The protoc compiler supports almost all the features of the protobuf 2 language and when given .proto files as input will generate the specialized Objective-C classes necessary to both read and write instances of the messages contained therein.

You write a .proto file like this: message Person { required int32 id = 1; required string name = 2; optional string email = 3;} Then you compile it with protoc, the protocol buffer compiler, to produce code in Objective-C. You use that code like this to produce raw protobuf data from a message: NSData* raw_data = ... Compiler Invocation. Compile protobuf 2.4.1 on iOS 5. Export ARCH=arm-apple-darwin10 export ARCH_PREFIX=${ARCH}- export PLATFORM=iPhoneOS export SDKVER=5.0 export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer export SDKROOT="$DEVROOT/SDKs/${PLATFORM}$SDKVER.sdk" export PKG_CONFIG_PATH="$SDKROOT/usr/lib/pkgconfig:$DEVROOT/usr/lib/pkgconfig" export AS="$DEVROOT/usr/bin/as" export ASCPP="$DEVROOT/usr/bin/as" export AR="$DEVROOT/usr/bin/ar" export RANLIB="$DEVROOT/usr/bin/ranlib" export CPP="$DEVROOT/usr/bin/llvm-cpp-4.2" export CXXCPP="$DEVROOT/usr/bin/llvm-cpp-4.2" export CC="$DEVROOT/usr/bin/clang" export CXX="$DEVROOT/usr/bin/clang++" export LD="$DEVROOT/usr/bin/ld" export STRIP="$DEVROOT/usr/bin/strip" export CPPFLAGS="-pipe -no-cpp-precomp -I$SDKROOT/usr/lib/gcc/${ARCH}/4.2.1/include -I$SDKROOT/usr/include -I$DEVROOT/usr/include" export CXXFLAGS="$CFLAGS -I$SDKROOT/usr/include/c++/4.2.1/${ARCH}/v6" export LDFLAGS="--sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$SDKROOT/usr/lib/system -L$DEVROOT/usr/lib" . make clean make make check make install.

Protocol Buffers for IOS. > Is there any direct support for Protocol Buffers in iOS? (armv6, > armv7) > > I have gone through he following link.. > > 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) .

To give you an idea this is what I directly compile Then you can use protoc to generate c++ source files for your protocol. Compile Protobuf for iOS » Niklas Saers' blog. For a project I’m doing at work, that I hope will eventually be open source, I needed to have protobuf compiled for iOS. A colleague of mine showed me how it had been compiled on iOS 4, using these scripts, but with iOS 5 I ended up with binaries compiled for the arm architecture instead of the armv7 architecture. Be aware that the iOS 5 SDK actually ships with a version of protobuf, but it’s a bit old, being version 2003001.

And it only ships the binary, not the headers. To compile protobuf, grab the latest source (which is 2.4.1 at the time of writing this) and run the following script (download script): After running this, you should have a directory called /tmp/protobuf/arm that is compiled for your iPhone or iPad with the armv7 architecture. Copy that into your project and start using protobuf. Protobuf ios. Jcayzac/play-protobuf.