I want to use protobuf(https://code.google.com/p/protobuf/) in my project
Did you successfully compile protobuf with xCode 5, Please help to share your experience?
Thanks.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With