This problem will exist even if #define MYCLASS MyClass was in any other header, not necessarily in the prefix header. This is because preprocessor directives are usually not imported into Swift. However, simple macros are imported if they can be mapped to global constants, which is possible for SOMEVAR , but not MYCLASS . See https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-ID17 .
You can use typealias in Swift in the global scope:
typealias MYCLASS = MyClass
Of course, type modifications must be changed if MYCLASS been redefined in the header.
This approach is not very useful, unfortunately, if the definition of MYCLASS changes depending on where / how the code is generated. However, since the code needs to know a little about the behavior common to various classes, which can be defined as MYCLASS , it is possible that protocols can be used here.
UPDATE: Thinking about playing a little more with him and reading some other posts, for example. Using obj-c typedef in Swift , here is the best solution I think. With this approach, you do not need to change your Swift code if MYCLASS is rec #define d in Objective-C.
Somewhere in your Objective-C code, for example. in the heading add
typedef MYCLASS * _MYCLASS;
which then allows you to do the following in Swift:
_MYCLASS.myClass().doStuff()
If you really insist on using MYCLASS in Swift for any reason, adding typealias MYCLASS = _MYCLASS to your Swift code will do the trick.