I'm trying to create an Objc class, with a property of an enum type, where the enum type is created in swift. After this, I want to use the Objc class in Swift.
(Swift)Enum:
import Foundation
@objc enum AffectsUnit:Int {
case time
case person
case group
}
(Objc)class
#import "JSONModel.h"
#import "MyApp-Swift.h"
@interface AddPlayerToTime : JSONModel
@property (nonatomic) AffectsUnit affectsUnit;
@end
The Objc class has an empty method file.
So far, so good. No compiler warnings.
Since i also want to use my objc class in Swift. I need to import the class in my Bridging-Header.h.
#import "AddPlayerToTime.h"
Now my swift code can see the AddPlayerToTime class, but the project will no longer compile. The error I get is:
Unknown type name 'AffectsUnit'
I'm 99% sure it breaks because of circular reference. Since my swift code is importing AddPlayerToTime class and AddPlayerToTime is importing my swift code. But I do not know how to fix this. All post on this circular reference matter, seem to suggest using @class declaration. But since I'm trying to refer to an enum, not a class, this is not a solution for me.
Am I trying to accomplish something, that simple can't be done?
Edit1: Please note: I want as much code as possible, to remain on the Swift side.