将protobuffer文件转换为objective-c
2015-11-02 17:37
453 查看
https://code.google.com/p/metasyntactic/downloads/list
ProtocolBuffers-2.2.0-Source
用命令 切换至ProtocolBuffers-2.2.0-Source
./autogen.sh
./configure
./make
./make install
这样在src目录下生成一个能够将.proto文件生成.m文件的命令行工具protoc.
2、如果make报错
则 找到 src/google/protobuf/message.cc
#include <istream> 再次执行
make 命令
3、如果还是没有生成protoc 命令工具,执行还有错误
这时需要安装brew
终端下载:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=3b2bb1f32f0d89e&k=master&k0=master&kdi0=0&luki=1&n=10&p=baidu&q=smileking_cpr&rb=0&rs=1&seller_id=1&sid=9ed8f0321fbbb203&ssp2=1&stid=0&t=tpclicked3_hc&td=1682280&tu=u1682280&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2FIOS%2F201505%2F450687%2Eshtml&urlid=0" target=_blank>master/install
完成后
brew install automake
这个地方会有一个Error 按照提示
输入命令
brew unlink automake
再次 brew install automake
brew install autoconfbrew
install libtool
然后重新操作第1步好了.
3、将一个 .proto文件(名字叫Person.proto)
直接使用文本编辑
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;
}
放到src 目录下
在src同级 建立build/objc 文件夹
调用命令src/protoc --proto_path=src
--objc_out=build/objc src/Person.proto 就会生成 Person.pb.h和Person.pb.m文件两个文件了,这两个文件中,包含的就是
对应的oc对象了,
4、使用
参考:http://www.cnblogs.com/uniy/archive/2011/12/21/2296405.html
其它参考:
http://blog.csdn.net/yohunl/article/details/41797621 http://ky-storm.cn/blog/445.html
ProtocolBuffers-2.2.0-Source
用命令 切换至ProtocolBuffers-2.2.0-Source
./autogen.sh
./configure
./make
./make install
这样在src目录下生成一个能够将.proto文件生成.m文件的命令行工具protoc.
2、如果make报错
则 找到 src/google/protobuf/message.cc
在
#include <google/protobuf/stubs/stl_util-inl.h>
下面添加
#include <istream> 再次执行
make 命令
3、如果还是没有生成protoc 命令工具,执行还有错误
这时需要安装brew
终端下载:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=3b2bb1f32f0d89e&k=master&k0=master&kdi0=0&luki=1&n=10&p=baidu&q=smileking_cpr&rb=0&rs=1&seller_id=1&sid=9ed8f0321fbbb203&ssp2=1&stid=0&t=tpclicked3_hc&td=1682280&tu=u1682280&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2FIOS%2F201505%2F450687%2Eshtml&urlid=0" target=_blank>master/install
完成后
brew install automake
这个地方会有一个Error 按照提示
输入命令
brew unlink automake
再次 brew install automake
brew install autoconfbrew
install libtool
然后重新操作第1步好了.
3、将一个 .proto文件(名字叫Person.proto)
直接使用文本编辑
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;
}
放到src 目录下
在src同级 建立build/objc 文件夹
调用命令src/protoc --proto_path=src
--objc_out=build/objc src/Person.proto 就会生成 Person.pb.h和Person.pb.m文件两个文件了,这两个文件中,包含的就是
对应的oc对象了,
4、使用
参考:http://www.cnblogs.com/uniy/archive/2011/12/21/2296405.html
其它参考:
http://blog.csdn.net/yohunl/article/details/41797621 http://ky-storm.cn/blog/445.html
相关文章推荐
- objective-c中的数字对象
- DeepID-Net:multi-stage and deformable deep CNNs for object detection
- IOS开发基础Object-C(06)—@property 和@synthesize语法
- UiObject官方文档,个人翻译
- Objective-C的反射
- Objective-OC中的Category(分类)
- Binarized Normed Gradients for Objectness Estimation at 300fps阅读笔记
- FMDB使用
- object-c编程tips-jastor自动解析
- Object-C NSSet类型
- JS入门之ActiveXObject对象
- Objective-C 入门博客链接
- Object-C系列-<present and dismiss>
- IOS开发基础Object-C(05)—OC变量的作用域、self
- Object-C系列-<深入CoreData与问题整理>
- qobject_cast用法
- org.hibernate.TransientObjectException: The given object has a null identifier:
- java 写出和读入 Object对象
- Objective-C 的现代语法和新特性
- 黑马程序员-------Objective-C基础