protobuf-swift
protobuf-swift copied to clipboard
Package name end with `.Protobuf` in proto3
protoc
$ brew update
$ brew install protobuf --devel --verbose
...
$ protoc --version
libprotoc 3.0.0
protobuf-swift
$ git clone https://github.com/alexeyxo/protobuf-swift
$ git checkout -b ProtoBuf3.0-Swift2.0 origin/ProtoBuf3.0-Swift2.0
$ ./scripts/build.sh
Cocoapods
pod 'ProtocolBuffers-Swift', :git => 'https://github.com/alexeyxo/protobuf-swift', :branch => 'ProtoBuf3.0-Swift2.0'
Error
if named package end with .Protobuf
, the swift
file will has wrong package name.
.proto
file
syntax = "proto3";
package Swift.Protobuf;
.swift
file
// Generated by the Protocol Buffers 3.0 compiler. DO NOT EDIT!
// Source file "api.proto"
// Syntax "Proto3"
import Foundation
import ProtocolBuffers
public struct Swift { public extension Protobuf}
OK
if package named end with other word like Swift.Protobuf1
, it's look good.
.proto
file
syntax = "proto3";
package Swift.Protobuf1;
.swift
file
// Generated by the Protocol Buffers 3.0 compiler. DO NOT EDIT!
// Source file "api.proto"
// Syntax "Proto3"
import Foundation
import ProtocolBuffers
public struct Swift { public extension Protobuf1 { }}
The word "Protobuf" is a reserved name for standard packages from google.
"Google.Protobuf" is a reserved name? But i see other language can supports "xxx.Protobuf" as package name.
I confirm, other languages support package name like com.something.somethingelse.protobuf. "protobuf" in package name doesn't seem to be reserved word.
I've encountered the same issue when tried to compile proto file from my project (actively used with several mainstream languages).