2

I'm trying to use the Swift class in my Object-c project. So far I have created the Objective-C project and imported the swift class and it asked me Would you like to configure an Objective-C bridging header?, then I hit Create Bridging Header so the productname-Bridging-Header.h file is created.

Then I changed

Always Search User Paths-->YES
SWIFT_OBJC_BRIDGING_HEADER-->YES

After that I import the swift class into my viewController.m class

Example: #import "Swiftclass.swift.h"

But it says #import "Swiftclass.swift.h" file not found

halfer
  • 19,824
  • 17
  • 99
  • 186
Vignesh
  • 592
  • 6
  • 25
  • 3
    Visit this link : http://stackoverflow.com/questions/32098696/import-swift-class-in-objective-c-mymodule-swift-h-file-not-found – Jigar Tarsariya May 18 '16 at 07:15
  • 2
    Check this. http://stackoverflow.com/questions/24102104/how-to-import-swift-code-to-objective-c – Wolverine May 18 '16 at 07:24
  • If you have created swift file in your project then to use it you need to import "ProjectName-swift.h" And also you should write this line in ".m files" only to avoid crytical refrences – Wolverine May 18 '16 at 07:25
  • Yes its running. I changed build settings --> Objective-C Generated Interface Header Name into mySwift class name -swift.h – Vignesh May 18 '16 at 07:45
  • Example SwiftClass-Swift.h – Vignesh May 18 '16 at 07:45

1 Answers1

3

You need to import ProjectName-Swift.h.

If your project name contain spaces, replace them with underscores (e.g. "My Project" becomes "My_Project-Swift.h")

Like,

 #import "My_Project-Swift.h"

Try like this. it will help you.

Jigar Tarsariya
  • 3,189
  • 3
  • 14
  • 38