Swift to Objective-C header does not contain Swift classes

前端 未结 8 2089
無奈伤痛
無奈伤痛 2020-12-16 12:18

I\'m attempting to use Swift classes in my Objective-C code, however my Swift classes don\'t seem to appear in the generated header. As a result, my build fails with \"Use o

8条回答
  •  忘掉有多难
    2020-12-16 13:09

    It is proper to use #import "TestAppModule-Swift.h" in your .m files. If you need to reference a class in a .h, use the @class forward declaration.

    Further, if you want to use a Swift class from Objective-C, the Swift class must be marked with the @objc attribute. Xcode will only include classes with that attributed in the generated header. See also this documentation.

提交回复
热议问题