Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate .proto files in Xcode compilation?

I am trying to port an android app to ios and new to mac/xcode ecosystem. My app uses Google proto buffs and using instructions at https://github.com/alexeyxo/protobuf-swift/blob/master/README.md I am able to build protobuf for swift and add ProtocolBuffers.xcodeproj to my project. I was even able to generate .swift files for my proto files outside of xcode using protoc directly. However, my question is how do I integrate .proto files in Xcode so xcode can find/compile them? Do I need to copy my .proto files manually in my project? I am using Xcode 7.2.1 and protoc version is 3.0.0. Thanks in advance.

like image 308
Abhijit Vaidya Avatar asked Mar 05 '16 00:03

Abhijit Vaidya


People also ask

What is Protobuf in iOS?

Protocol buffers are a language-agnostic method for serializing structured data that can be used as an alternative to XML or JSON in your iOS apps.

How do I create a proto file?

proto file are simple: you add a message for each data structure you want to serialize, then specify a name and a type for each field in the message. Here is the . proto file that defines your messages, addressbook. proto .


1 Answers

  1. Create a build rule for *.proto files, something like this: enter image description here
  2. Add your .proto file to "Compile Sources" build phase list.
like image 149
silyevsk Avatar answered Oct 11 '22 21:10

silyevsk