Using Protocolbuf in Mac/ios

Source: Internet
Author: User


using https://github.com/mingchen/protobuf-ios First is to download it down
it uses the command line .
$ cd compiler$ ./autogen.sh$ ./configure$ make$ make install (optional)

The compiler is genrated at src/protoc . In the SRC directory, generate a command-line tool PROTOC that can generate. m files from the. proto file .
Of course, the installation process encountered several problemsyou need to install brew first, this installation process, the direct use of the official installation method can be installed, is a word,Brew can be used for easy installation of software
http://brew.sh Https://github.com/Homebrew/homebrew
installation, as long as a commandruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
after installation, you need to install it again.Brew Install Automake
Brew Install autoconfAlso, you may be prompted for a lack of libtool using the command brew install Libtool installation
when the final make command is executed, you will still encounter an error [Message.lo] 1 and need to change the file message.cc
+ #include <istream> (add this line)


How to useput a. proto file (called Person.proto), such as the followingmessage Person {
Required String name = 1;
Required Int32 id = 2;
Optional String email = 3;


Enum Phonetype {
MOBILE = 0;
HOME = 1;
Work = 2;
}


Message PhoneNumber {
Required String number = 1;
Optional Phonetype type = 2 [default = HOME];
}


Repeated PhoneNumber phone = 4;
}

in the SCR directory, and then create a folder in the SRC peer BUILD/OBJCInvoke CommandSrc/protoc--proto_path=src--OBJC_OUT=BUILD/OBJC Src/person.proto will generateperson.pb.h and person.pb.m file two files, and these two files contain the corresponding OC object,

https://code.google.com/p/protobufeditor/this is. Proto's editing tools

   Reference Document Http://www.cnblogs.com/uniy/archive/2011/12/21/2296405.html
http://blog.csdn.net/hherima/article/details/17172441http://blog.csdn.net/hherima/article/details/21534673https://gist.github.com/BennettSmith/7150245

Using Protocolbuf in Mac/ios

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.