协议缓冲区代码为iOS模拟器而不是设备编译

时间:2017-08-09 20:47:04

标签: ios swift xcode protocol-buffers grpc

我在iOS应用中使用github.com/apple/swift-protobuf tag 0.9.904github.com/grpc/grpc-swift tag 0.1.12 Xcode。我也使用与protoc相同的版本来编译我的.proto文件。

该应用程序在iOS模拟器中运行正常但是当我尝试在我的设备上运行应用程序时,我在myapp.pb.swift中生成的代码中出现了编译错误:

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

错误是

No type named 'ProtobufAPIVersion_2' in module 'SwiftProtobuf'

Type '_GeneratedWithProtocGenSwiftVersion' does not conform to protocol 'ProtobufAPIVersionCheck'

对导致错误的代码的评论不言而喻。但是,如果这是真的,为什么应用程序在模拟器中编译并运行良好?我怎样才能在设备上编译和运行它?

1 个答案:

答案 0 :(得分:0)

如果这仍然是您的问题,请在swift-protobuf项目上提交GitHub问题。