NSApplication principal class not seen in static lib

So I've finally decided I've had enough with dynamically loaded libraries and am moving my remaining code base to a static library. One of the things I do is override sendEvent, which requires sub-classing NSApplication and setting the app's principal class to my subclass. Worked great in my dynamically loaded "framework", but now that it's in a static library, when the application attempts to launch, it says it cannot find the principal class and exits. Bummer. So after some fiddling around, I found that if I just trick it a little, it sees it. The way I'm doing the "trick" is like this:

That's all I have to do to make the class visible on launch (the principal class is set to tqMacApplication). As the method implies, I never actually call it. Just having the alloc there is enough to do the trick.

Could someone explain to me why this is so?

Also, is there a more elegant way of getting the class noticed on launch for the principal class? The way I'm doing it right now obviously reeks of hackishness.

Well, it appears that I may have found out why this is so at this link. Still not ideal because it loads *everything*, but for my situation, it might be just fine. However, I tried adding the -ObjC flag to the other linker flags in the application which uses the library (not the library itself) and it still doesn't work. Hmm...

You can use -Objc in "other linker flags" to make sure that all ObjC classes are loaded in all linked modules, otherwise it's done lazily, so if there's no module actually referencing that class, the ObjC runtime won't ever get to see it, as the "static" linker (i'm sure OSC will complain about this) will simply skip it.

So, your method call, while never actually used, forces the symbols to be linked, so that a runtime function like NSClassFromString(), which is how the "principal class" is got from the class name, sees it.