• 从零使用protobuf


    一、pod入ProtocolBuffers
     
    二、Build Phases里面Link Binary With Libraries导入libProtocolBuffers.a
     
    三、把  *.proto  文件导出为OC文件
     
    1、下载Protocol Buffers for Objective-C
    2、先把一些必要写入文件的文件夹修改权限:
    /usr/local
    /usr/local/bin
    /usr/local/opt
    /usr/local/Library/LinkedKegs
    逐个右键点击上面每一个文件夹 -> 显示简介 -> 右下角开锁 -> 把所有“只读”改为“读与写”。
    事后可以改回来。(或者在命令前加sudo)
     
    3、安装Objective-C Protobuf 编译器
     
    a、Check if you have Homebrew(在终端运行下面红字这个指令,如果有安装Homebrew,即可看到版本)
         brew -v
    b、If you don't already have Homebrew, then install it(如果没有安装过,就运行下面的指令安装)
         ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    c、Install the main Protobuf compiler and required tools
         sudo chmod a+w /usr/local/Cellar 
         brew install automake
         如果不运行sudo那个命令,有机会会报错如下:
         Error: Cannot write to /usr/local/Cellar
         
         安装到这步,估计会发生好多Error: ,遇到错误提示,可以用下面的命令,看看问题在哪:
         brew doctor
         ********************************************
         1、Warning: /usr/local/lib isn't writable.
               这个是说没有写权限,用上述第2点的方法,逐个文件夹修改权限。
         2、Error: You must `brew link autoconf' before automake can be installed
              brew link --overwrite --dry-run autoconf
         ********************************************
         brew install libtool
         brew install protobuf
         ********************************************
         可能存在下载不了的情况,此时可以尝试更换homebrew的镜像:
          sudo git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git
          sudo brew update
         
    就是利用brew下载安装了。protobuf就是我们想要的,这是依赖库:
    git clone https://github.com/alexeyxo/protobuf-objc.git
    d、(optional) Create a symlink to your Protobuf compiler. ln -s /usr/local/Cellar/protobuf/2.6.1/bin/protoc /usr/local/bin
    e、Clone this repository. git clone https://github.com/alexeyxo/protobuf-objc.git
    f、Build it! ./scripts/build.sh
  • 相关阅读:
    CCS3.3安装常见问题(以合众达的为例)
    typedef unsigned long (__stdcall *THREADFUNC)(void *)
    Prism学习(8)模块间通讯
    Prism学习(6)Shell Region View
    Prism学习(4)弃远就近UnityBootstrapper
    Prism学习(2)初识Unity
    Prism学习(5)Hello Silverlight
    Prism学习(1)前期准备
    Prism学习(7)Commands
    Prism学习(9)阶段性总结
  • 原文地址:https://www.cnblogs.com/billios/p/5787165.html
Copyright © 2020-2023  润新知