import swift class in objective-c, -Swift.h file not found

后端 未结 10 1558
野性不改
野性不改 2020-12-02 15:41

I have an iOS project written with Objective-C. I created an Swift class in the project, the bridging header file for accessing objective-c in Swift is generated successfull

相关标签:
10条回答
  • 2020-12-02 16:18

    I ran into the same issue yesterday and worked for hours to fix it with no avail. Others may have been in the same boat as I. I did all of the steps described above, but nothing worked.

    The cause of mine breaking was because of project name artifacts all over my project (from previously changing its name improperly).

    If all of the above steps fail, I would suggest doing like I did and renaming your project so that Xcode can reset somethings... That solved the problem for me. Doing so worked like a charm!

    0 讨论(0)
  • 2020-12-02 16:19

    In case anybody is wondering why after spending hours on this issue it is still unresolved, you might be in a situation similar to mine, where I was actually developing a framework, rather than an app.

    In such case, the format of the import statement for Objective-C Generated Interface Header is as follows:


    #import <ModuleName/ModuleName-Swift.h>
    
    0 讨论(0)
  • 2020-12-02 16:22

    In my case, I have forgotten to check a swift framework to the target/classes that I was using it, really specifically case but it may help someone in the future.

    0 讨论(0)
  • 2020-12-02 16:23

    This is not an exact answer but more of a workaround, but can save you time in some difficult cases. If you, as suggested by some of the the previous answers, can actually find the swift header buried inside the derived data folder, you are allowed to import it using the full path. This is not specific to the swift header, instead it can be applied to any header. Hope you can find this answer useful.

    0 讨论(0)
提交回复
热议问题