Jem*_*Ryu 5 import xcode thrift ios swift
我正在尝试在 Xcode 中建立一个支持 Thrift 0.12 和 Swift 4.2 的新项目。在我由 Thrift 生成的 swift 文件中,所有文件都有“import Thrift”这一行,但我收到编译错误“No such module 'Thrift'”。我不知道如何解决这个问题。将 Thrift 作为 cocoapod 导入似乎不起作用,因为我可以下载的最新版本虽然 pod 似乎是 0.10,但它不支持 Swift 4.2。我已经将 Thrift 0.12 下载到我的 Mac 上,这就是我首先生成 thrift-to-swift 文件的方式。下面是生成的文件之一。
我曾尝试:
pod "Thrift"和
pod 'Thrift-swift3', :git => 'git@github.com:apache/thrift.git', :branch => 'master'
他们都不工作。
我生成的swift文件:
import Foundation
import Thrift
public final class TTestMessage {
public var title: String?
public var message: String?
public init() { }
public init(title: String?, message: String?) {
self.title = title
self.message = message
}
}
Run Code Online (Sandbox Code Playgroud)
我为 Swift 4.2+ 兼容性做了一个 PR(https://github.com/apache/thrift/pull/1827)并且它被合并了。
因此,现在 Podfile 中的有效解决方案如下:
pod 'Thrift', :git => 'git@github.com:apache/thrift.git'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
297 次 |
| 最近记录: |