Google Protocol Buffers on iOS / Objective-C

I need help setting up / using protobuf in Objective-C for an iOS app. I tried everything, but I keep getting errors on xcode. Has anyone managed to make protobuff work well in Objective-C / iOS?

+4
source share
1 answer

I used it to some extent on iOS, and with a metasynthetic extension , it works very well. I even managed to get code generation as a custom build step in Xcode. We switched to Thrift for our project (for other reasons), so I apologize if some of the details below are wrong, but overall 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 the "* .proto" files.
  • In "Use:" select "custom script" and use the script as follows:

    protoc --plugin=/usr/local/bin/protoc-gen-objc $INPUT_FILE_PATH --objc_out=$DERIVED_FILES_DIR

  • In the output files, add the generated files (there must be two files, $(INPUT_FILE_BASE).pb.m and $(INPUT_FILE_BASE).pb.h .

  • Add .proto files to your project.
+3
source

Source: https://habr.com/ru/post/1389660/


All Articles