ios - 如何将 Thrift 0.12 导入 Xcode 以支持 Swift 4.2

标签 ios swift xcode import thrift

我正在尝试在 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
  }
}

最佳答案

我为 Swift 4.2+ 兼容性做了一个 PR ( https://github.com/apache/thrift/pull/1827 ),它被合并了。

因此,现在您的 Podfile 中的工作解决方案如下:

pod 'Thrift', :git => 'git@github.com:apache/thrift.git'

关于ios - 如何将 Thrift 0.12 导入 Xcode 以支持 Swift 4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56841613/

相关文章:

ios - 从 OpenCV 距离变换得到奇怪的结果

swift - 为什么这个有类型问题的 Swift 代码不会生成错误?

ios - 为什么在字符串数组上使用连接会导致段错误 : 11 error on archiving in XCode?

iOS 10 - 每 "x"分钟重复一次通知

swift - Firebase 在 TableView 中检索和插入

c 在 xcode : Redeclaration of function must have the overloadable attribute error

swift - 类型 '(Any) -> ()' 的值没有成员 'currentTitle'

ios - collectionView 函数 didSelectItemAt indexPath 将数据传递到下一个 View Controller

ios - 在 Git 推送和克隆后,找不到 -lCocoaAsyncSocket XCode 7.3 的错误库

ios - 应用程序在自定义相机期间无声崩溃 (Swift)