0

My project is a Swift project, which contains custom class in Objective C. Now I'm trying to use an another custom class which is in Swift in my Objective C class. I'm able to get the class, but all it's methods are not accessible.

Project : Swift

Custom Library : Swift

Want to use in : Objective C (another custom library)

All the methods are public in that custom class, but still I'm unable to access it. I had also followed this. Please guide me

Any help will be appreciated.

Community
  • 1
  • 1
Ankita Shah
  • 2,178
  • 3
  • 25
  • 42
  • 1
    Can't help because I never did this , but [this](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-ID122) may help. – Nick Allen Feb 17 '16 at 05:48
  • Can you see your methods inside your myproject-Swift.h ?? – Keerthi Shekar Feb 17 '16 at 05:54
  • Possible duplicate of [Can't use Swift classes inside Objective-C](http://stackoverflow.com/questions/24206732/cant-use-swift-classes-inside-objective-c) – nielsbot Feb 17 '16 at 05:59
  • @nielsbot it's different. I'm making the edit – Ankita Shah Feb 17 '16 at 06:22

1 Answers1

0

Yes,you can use when u are drag and drop the objective class then one bridge file is created and this file import the objective c class .h file like import "test.h"

ketan
  • 11
  • 3
  • Thanks for you'r reply. Bridging file is included included, because of which I'm able to use that custom Objective C class. I want to include Custom Swift class in that Objective C class. Please check my question again – Ankita Shah Feb 17 '16 at 06:35
  • You need to import ProjectName-Swift.h. Note that it's the project name - the other answers make the mistake of using the class name. This single file is an autogenerated header that defines Objective-C interfaces for all Swift classes in your project that are either annotated @objc or inherit from NSObject. – ketan Feb 17 '16 at 06:42
  • I had done that only for importing Swift to Objective C. I can get the class, but I'm unable to use it's methods – Ankita Shah Feb 17 '16 at 06:51