0

I have two classes, (an obj-c, and a swift). I would like to call a function from swift class. I tried to import my swift class as the following shows:

#import <MyProjName-Swift.h>
#import <MyClassName-Swift.h>
#import <MyProjName/MyClassName-Swift.h>

But none of these worked.

Error: file not found

How could I import my Swift class into my Obj-C class?

Is there anywhere an existing open source project which uses Swift and Objective-C classes in one project?

andras
  • 11
  • 1
  • check this reference https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/MixandMatch.html – Pawan Rai Dec 03 '14 at 06:48
  • possible duplicate of [How to import Swift code to Objective-C](http://stackoverflow.com/questions/24102104/how-to-import-swift-code-to-objective-c) – Matt Gibson Dec 03 '14 at 08:27
  • 1) `#import "MyProdName-Swift.h"`—it's the Product name, which is normally the same as the Project name, but that's worth checking in the build settings (Target/Build Settings/Packaging/Product Name). And Apple indicate you should use double quotes, not angle brackets, as would be normal with an include file that's local to your project, as opposed to a system one. 2) Is your Swift class derived from NSObject? 3) Do you have a [module name](http://stackoverflow.com/questions/24062618/swift-to-objective-c-header-not-created-in-xcode-6/24064015#24064015) set? – Matt Gibson Dec 03 '14 at 08:34
  • (Also, when you say "none of these worked", it's always helpful to say exactly what didn't happen that you were expecting, and any error messages that were produced.) – Matt Gibson Dec 03 '14 at 08:36
  • Thanks for your help your first solution worked. The different project and product name was the problem. – andras Dec 15 '14 at 13:49

0 Answers0