Use protocolBuf and iosprotocolbuf in MAC/IOS

Source: Internet
Author: User

Use protocolBuf and iosprotocolbuf in MAC/IOS

Using the https://github.com/mingchen/protobuf-ios is first downloaded
It uses the command line

$ cd compiler$ ./autogen.sh$ ./configure$ make$ make install (optional)

The compiler is genrated src/protoc. Generate a command line tool protoc under the src directory that can generate the. proto file. m file.
Of course, you have encountered several problems during the installation process. You need to install brew first. During the installation process, you can directly use the official installation method to install brew, brew can be used to install software conveniently.
Http://brew.sh https://github.com/Homebrew/homebrew
Install, just one command ruby-e "$ (curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
After installation, you need to install brew install automake again.
Brew install autoconf and may also prompt the lack of libtool to use the command brew install libtool to install
After the installation is complete, the Error [message. lo] Error 1 will still occur when the last make command is executed. You need to change the file message. cc.
#include <google/protobuf/stubs/stl_util-inl.h> 
+ # Include <istream> (add this line)


Use a. proto file (Name: Person. proto), for example, the following message 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;
}

Put it in the scr directory, and create the build/objc folder at the src same level to call the command src/protoc -- proto_path = src -- objc_out = build/objc src/Person. proto will generate Person. pb. h and Person. pb. the m file contains the corresponding oc object,

Https://code.google.com/p/protobufeditor/, this is an editing tool for. proto.

Reference 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

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.