0

I am currently working on an Objective C project and need few swift files support in it. According to Apple official guidelines, after I create a bridging header, I did this

#import "ProjectName-Swift.h"

to access the swift classes. It didn't work. So, I changed the "Defines Module" to "YES", rewrote the header prefixing with the module name, all to vain. Then I thought of switching the compiling language to "Swift 3" and voila, it works! App runs on the phone.

However, there are few plugins and frameworks that I am also using which don't work with Swift 3. So, no peace here. I need a solution. Help!

Vijay Kumar Kanta
  • 1,111
  • 1
  • 15
  • 25
  • What version of Xcode are you using? When you say "plugins and frameworks that ... don't work with Swift 3" are you saying that they're using Swift 4.x? Or Swift 2.x? Perhaps you can give us steps to create [MCVE](https://stackoverflow.com/help/mcve)... – Rob Dec 28 '18 at 18:10
  • What do you mean "it didn't work"?? What error did you get? – thomas gotzsche Dec 28 '18 at 20:35
  • @Rob Xcode is latest 10.1 (10B61). All plugins and frameworks are supporting for Swift 4. – Vijay Kumar Kanta Dec 29 '18 at 02:23
  • @thomasgotzsche the error is "File not found" when I am in Swift 4, but not when I am in Swift 3, the error goes away, compilation "succeeds", however in runtime the app breaks saying the particular plugin won't work. When I remove the swift classes and run it simply, every thing works in Swift 4, but for my swift classes I need the header. – Vijay Kumar Kanta Dec 29 '18 at 02:24

2 Answers2

3

So finally after searching the web an another SO post (answer) helped me out. It could be because of bridging issues or compiling thing, I have to "BUILD" the project to get the header generated or something. The solution was from this post https://stackoverflow.com/a/45338549/8102549 or here

Vijay Kumar Kanta
  • 1,111
  • 1
  • 15
  • 25
0

Check out your Build settings for Objective-C generated Interface Header Name make sure that the Install Objective-C Compatibility Header is set to Yes. Also, ensure the file name there is as you expect.

thomas gotzsche
  • 367
  • 2
  • 7
  • They're all set perfectly. It just won't find the header generated header file in the "AppDelegate.m" file which is where I want to use them. – Vijay Kumar Kanta Dec 29 '18 at 02:26