Install the protoc compiler that is used to generate gRPC service code. The simplest way to do this is to download pre-compiled binaries for your platform(protoc--.zip) from here: https://github.com/google/protobuf/releases
Unzip this file.
Update the environment variable PATH to include the path to the protoc binary file.
Inside SwiftProtobuf pod, there is generated empty.pb.swift
public struct Google_Protobuf_Empty {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
public var unknownFields = SwiftProtobuf.UnknownStorage()
public init() {}
}
To consume, we can
import SwiftProtobuf
let empty = Google_Protobuf_Empty()
oneof mode
message Person {
oneof mode {
Human human = 1;
Superman superman = 2;
}
}
Cannot convert value of type 'Server_Person.OneOf_Mode' to expected argument type 'Server_Human'
Need to assign the mode
var person = Person()
person.mode = Person.OneOf_Mode.Human()
protoc
https://grpc.io/docs/quickstart/go.html
Go protoc plugin
https://github.com/golang/protobuf
Swift protoc plugin
https://github.com/grpc/grpc-swift
Generate
In case we need to cd
Empty
If remote import is needed, then the workaround is to download the that proto locally, for example empty.proto https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto
Inside SwiftProtobuf pod, there is generated
empty.pb.swift
To consume, we can
oneof mode
Need to assign the mode