Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@Nonchalant

Swift - ProtocolBuffersをはじめる

More than 1 year has passed since last update.

個人用のメモ書きです

環境

Swift: 4.0.3

protobufのインストール

$ brew install protobuf

Appleが提供しているプラグインを使う

$ git clone https://github.com/apple/swift-protobuf.git
$ cd swift-protobuf
$ git checkout tags/1.0.2
$ swift build

ビルドしたプラグインを指定して、.protoファイルをコンパイル

$ $ protoc --plugin=protoc-gen-swift=.build/debug/protoc-gen-swift --swift_out=. *.proto

パスを通しておく

$ mkdir ~/.protoc
$ cp .build/debug/protoc-gen-swift ~/.protoc/protoc-gen-swift
$ echo 'export PATH=$PATH:$HOME/.protoc' >> ~/.zshrc
$ source ~/.zshrc

Option

アクセス修飾子などの各種オプションは--swift-optで設定することができます。詳細は以下で確認できます。

参考

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?