Search code examples
objective-cswiftbridging

Objective C interface generated header can't be imported in other header


I am not an Obj C pro, but I should write some code in Objective C and bridge a Swift code to it. I success in importing the Generated Header to the .m file:

#import "<my_module>-Swift.h"

But when I try importing the same header to the .h file it throws this error: enter image description here

BTW, I only want to add a public variable that instances from a Swift class to a specific obj c class. I've tried to put these lines at the .h and .m files:

@property (nonatomic, readwrite, strong) Card *card;

What should I do?


Solution

  • In your case, since all you need to do is declare a property of type Card*, you don't actually need to import the header—you can just forward-declare the class with @class Card; before using it.