Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Thrift 0.12 into Xcode to support Swift 4.2

I am trying to set up a new project that supports Thrift 0.12 and Swift 4.2 in Xcode. In my swift files that were generated by Thrift, all of them have the line "import Thrift", but I get a compile error "No such module 'Thrift'". I am at a loss on how to resolve this issue. Importing Thrift as a cocoapod does not seem to work because the latest version I can download though a pod seems to be 0.10, which does not support Swift 4.2. I have Thrift 0.12 downloaded onto my mac, which is how I generated the thrift-to-swift files in the first place. Below is one of the generated files.

I have tried: pod "Thrift" and pod 'Thrift-swift3', :git => '[email protected]:apache/thrift.git', :branch => 'master' Neither of them work.

My generated swift file:

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
  }
}
like image 963
Jemin Ryu Avatar asked Oct 16 '22 13:10

Jemin Ryu


1 Answers

I made a PR for Swift 4.2+ compatibility (https://github.com/apache/thrift/pull/1827) and it was merged.

So a working solution is now the following in your Podfile:

pod 'Thrift', :git => '[email protected]:apache/thrift.git'
like image 132
Cœur Avatar answered Oct 18 '22 14:10

Cœur