Using Swift classes inherited from Objective C library code in Objective C code

I am working on a Swift project using a couple of ObjC libraries. One of them is SWTableViewCell . My app list box cells inherit from SWTableViewCell

, a subclass UITableViewCell

that adds swiping action to cells.

Libraries are added using cocoapods.

I want to import Swift code into ObjC in my main project. project-Swift.h

is generated as it should (every Swift class inheriting from NSObject, annotated as @objc, included), but it contains errors:

project-Swift.h:135:31: Cannot find interface declaration for 'SWTableViewCell', superclass of 'MySWTableViewCell'; did you mean 'UITableViewCell'?

      

How do I fix this situation? I need a header that will be generated correctly in order to use the Swift classes in ObjC My goal is to either ignore these classes or let Xcode that it needs to import an additional header duringproject-Swift.h

+3


source to share


1 answer


This should fix your problem:



  • Create a header file in your project: File> New> File> (iOS or OS X)> Source> Header File
  • In your Objective-C bridge header file, import the required Objective-C headers you want to expose to Swift: in your case, you need #import "SWTableViewCell.h"

+2


source







All Articles