Google protocol buffers on iOS

后端 未结 4 1931
情书的邮戳
情书的邮戳 2020-12-07 17:23

Is the metasyntactic static library for iOS . . .

http://code.google.com/p/metasyntactic/wiki/ProtocolBuffers

. . . compatible with regular old C++ compiled

4条回答
  •  悲&欢浪女
    2020-12-07 17:46

    You can add support for Google Protocol Buffers to an Xcode 5 project using Cocoapods by adding the following line to your Podfile.

    pod 'GoogleProtobuf', '~> 2.5.0'
    

    This will place the C++ version of the protobuf code into a Pod for your project. It will also add the protoc compiler in the folder Pods/GoogleProtobuf/bin/protoc within your project.

    You can create a custom build rule in your project that automatically converts the .proto files into .ph.{h,cc} files. Here is how I did that:

    Setup a build rule to "Process Source files with names matching: *.proto Using Custom Script". The script should include the following:

    cd ${INPUT_FILE_DIR}
    ${SRCROOT}/Pods/GoogleProtobuf/bin/protoc --proto_path=${INPUT_FILE_DIR} ${INPUT_FILE_PATH} --cpp_out=${INPUT_FILE_DIR}/cpp
    

    Set the output files to include the following:

    $(INPUT_FILE_DIR)/cpp/$(INPUT_FILE_BASE).pb.h
    $(INPUT_FILE_DIR)/cpp/$(INPUT_FILE_BASE).pb.cc
    

    Any .proto files you include in your project will now automatically be converted to C++ and then compiled as part of your build.

提交回复
热议问题