I need help to configure/use protobuf in Objective-C for a iOS app. I've tried all but I keep getting errors on xcode. Did anyone manage to make protobuf work well in Objective-C/iOS?
Asked
Active
Viewed 5,958 times
1 Answers
3
I have used it to some extent on iOS, and with metasyntactic's extension, it works really well. I even managed to get the code generation as a custom build step in Xcode. We switched to Thrift for our project (for other reasons), so my apologies if some details below are wrong, but in general this is how to do it.
- In Xcode 4.2, open the target properties, go to the "Build Rules" tab and create a new build rule for "*.proto" files
In "Using:", choose "custom script" and use a script like this:
protoc --plugin=/usr/local/bin/protoc-gen-objc $INPUT_FILE_PATH --objc_out=$DERIVED_FILES_DIR
In Output files, add the generated files (there should be two files,
$(INPUT_FILE_BASE).pb.m
and$(INPUT_FILE_BASE).pb.h
.- Add the .proto files to your project.

Krumelur
- 31,081
- 7
- 77
- 119
-
I'm trying to use that extension. The compiler works ok but when I do the project integration I get [this](http://stackoverflow.com/questions/8745661/undefined-symbols-for-architecture-i386-using-protobuf) and [this](http://stackoverflow.com/questions/8746194/unable-to-open-executable-xcode) errors... Are you using xcode 4.2? Maybe I did the project integration wrong, since it's no really the same as they say in the website because I'm using xcode 4.2... – Filipe Mota Jan 06 '12 at 15:18
-
How did you get the project they metasyntactic tells you to list as a dependency to work? I get errors in the ProtocolBuffer project's source files (due to being outdated), which won't let me compile. – Groppe Feb 22 '12 at 20:24
-
It was a while since I tried it, but IIRC it build when I tried it, or at least the build errors were trivial to fix. What errors are you getting? – Krumelur Feb 27 '12 at 09:19