Is there a way to reference a Swift enum from an Objective-C header? If you want to see Swift classes in the Objective-C header you can use
@objc class Foo
I don't see anything similar for enums.
What you want to do is called forward declaration
. To forward declare an enum you can do:
enum name;
But since the compiler won't know the size of the enum, you will only be able to use it as a pointer in your header file. Even doing this might prove problematic if you use compiler flags like -pedantic
.
So in short, there is no good way to do this. Your best bet is not to, and access the enum from your implementation (.m) file instead.
In your implementation file, #import
your swift bridging header file, and, without knowing more details about your problem, you could add private properties that use your enum like this:
@interface MyObjCClassDefinedInTheHFile() @property (nonatomic, assign) SomeSwiftEnum type; @end
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With