我在iOS应用中使用github.com/apple/swift-protobuf tag 0.9.904和github.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'
对导致错误的代码的评论不言而喻。但是,如果这是真的,为什么应用程序在模拟器中编译并运行良好?我怎样才能在设备上编译和运行它?