Use Objective-C code in a Swift project that simultaneously uses Swift code

I have a Swift project in which I use the Objective-C class. I did this by importing the .h file inside my header header. Everything is working fine.

Now I need to use the Swift class inside this Objective-C code, so I imported $ ModuleName-Swift.h into the Objective-Ch file. Now Xcode complains that this file was not generated. The interesting part: when I do not import the Objective-Ch file inside the bridge header (therefore, I do not use Objective-C code in my Swift project), the $ ModuleName-Swift.h file works, and I can use the Swift code inside my Objective-C code .

Is there only one way solution? (use fast code in objc or vice versa)

thank

+4
source share
1 answer

Imported $ ModuleName-Swift.h inside your objc.m file.

If you need your fast class in the objc.h file, write @class YourSwiftClass;after the lines #importin the .h file

0
source

Source: https://habr.com/ru/post/1651672/


All Articles