protobuf-swift icon indicating copy to clipboard operation
protobuf-swift copied to clipboard

Package name end with `.Protobuf` in proto3

Open langyanduan opened this issue 8 years ago • 3 comments

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 { }}

langyanduan avatar Apr 22 '16 05:04 langyanduan

The word "Protobuf" is a reserved name for standard packages from google.

alexeyxo avatar Apr 22 '16 06:04 alexeyxo

"Google.Protobuf" is a reserved name? But i see other language can supports "xxx.Protobuf" as package name.

langyanduan avatar Apr 22 '16 06:04 langyanduan

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).

kosciej avatar May 05 '16 22:05 kosciej