美文网首页
Swift 安装protobuf

Swift 安装protobuf

作者: 青年fw | 来源:发表于2019-05-22 18:37 被阅读0次

1、官方项目地址:https://github.com/apple/swift-protobuf

2、拉取项目到本地

$ git clone https://github.com/apple/swift-protobuf.git

3、进入项目本地路径,查看版本

$ cd swift-protobuf
image.png

4、根据项目需要,选择版本编译 如:1.5.0

$git checkout tags/1.5.0

5、构建项目

$swift build -c release -Xswiftc -static-stdlib

6、构建完成之后会生成一个protoc-gen-swift执行路径:swift-protobuf/.build/release/protoc-gen-swift

image.png

7、把protoc-gen-swift文件直接拷贝到/usr/local/bin目录下

cd /usr/local/bin/
image.png

8、swift版本的protobuf已安装完成,现在可以来测试使用
准备一个proto文件(Book.proto)

syntax = "proto2";
message BookInfo {
  optional int64 id = 1;
  optional string title = 2;
  optional string author = 3;
}

9、生成swift文件

$ protoc --swift_out=. Book.proto

10、把生成的Book.swift文件拖入到项目中就可以使用了


image.png

相关文章

  • 2020-09-27

    Mac安装 swift-protobuf git clonehttps://github.com/apple/sw...

  • swift5 protobuf集成苹果官方版总结

    Swift-Protobuf 的安装使用总结 安装环境 Ruby MAC_Ruby 安装 - 简书 Brew M...

  • Swift 安装protobuf

    1、官方项目地址:https://github.com/apple/swift-protobuf 2、拉取项目到本...

  • mac上安装Protobuf

    为什么要安装protobuf 什么是protobuf 怎么判断有没有安装过protobuf? 安装protobuf...

  • 你应该懂得protobuf

    某大牛封装的(protobuf-swift) 苹果封装的(swift-protobuf) 本文记录配置环境过程,不...

  • iOS开发环境搭建

    一、安装cocoapods 安装cocoapods 二、安装protobuf 安装protobuf使用方式:pro...

  • gRPC之python

    安装 安装grpc 安装python grpc的protobuf的编译工具 安装protobuf的python依赖...

  • protobuf使用

    protobuf的使用 protobuf .proto文件 idea安装protobuf插件 syntax = ...

  • Ubuntu16.04安装protobuf 2.6.1

    Ubuntu上安装protobuf 和protobuf-c 1、下载安装包protobuf-2.6.1,解压 2、...

  • iOS Protobuf快速集成

    安装Protobuf 使用命令 brew install protobuf 安装前可能需要先安装autoconf和...

网友评论

      本文标题:Swift 安装protobuf

      本文链接:https://www.haomeiwen.com/subject/ilbuzqtx.html