All classes in ObjC must conform to the objc_object
structure. In the vast majority of cases, that means it's a subclass of NSObject
. There are a few other ways that classes can conform to the objc_object
structure: subclassing NSProxy
or just by cleverly laying out their own structure to happen to match it and adding hooks, often in the system libraries, to deal with the differences, like in toll free bridging or libSystem. Swift objects by default do not do this, so they aren't visible to ObjC.
Adding @objc
isn't what you need. In fact, that generally won't compile. You need to make the class a subclass of NSObject
. That's a significant change that you can't make with compiler options. It changes memory layout, message dispatching, and other behaviors. You need to change the source code and recompile at least.