How can I add forward class references used in the -Swift.h header?

Posted by Bill on Stack Overflow See other posts from Stack Overflow or by Bill
Published on 2014-06-07T14:49:38Z Indexed on 2014/06/07 15:24 UTC
Read the original article Hit count: 441

Filed under:
|

I'm integrating Swift code into a large Objective-C project, but I'm running into problems when my Swift code refers to Objective-C classes. For example, suppose I have:

  1. An Objective-C class called MyTableViewController
  2. An Objective-C class called DeletionWorkflow

I declared a Swift class as follows:

class DeletionVC: MyTableViewController {
  let deleteWorkflow: DeletionWorkflow

  ...
}

If I now try to use this class by importing ProjectName-Swift.h into Objective-C code, I get undefined symbol errors for both MyTableViewController and DeletionWorkflow.

I can fix the problem in that individual source file by importing DeletionWorkflow.h and MyTableViewController.h before I import ProjectName-Swift.h but this doesn't scale up to a large project where I want my Swift and Objective-C to interact often.

Is there a way to add forward class references to ProjectName-Swift.h so that these errors don't occur when I try to use Swift classes from Objective-C code in my app?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about swift-language