I want to make use of a private framework on iOS from a Swift app. I am well aware why this is a bad idea, but it will be useful during testing, so App Store limitations are not an issue, and I have quite exhaustively looked into alternatives.
What I would like to do is something along the lines of this:
dlopen("/Developer/Library/PrivateFrameworks/UIAutomation.framework/UIAutomation".fileSystemRepresentation,RTLD_LOCAL);
let eventsclass = NSClassFromString("UIASyntheticEvents") as? UIASyntheticEvents.Type
eventGenerator = eventsclass!.sharedEventGenerator() as! UIASyntheticEvents
The problem is that this will cause a linker error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_UIASyntheticEvents", referenced from:
type metadata accessor for __ObjC.UIASyntheticEvents in Test.o
If I link the framework directly rather than use dlopen(), it will work fine on the simulator, but will fail to build for an actual device, as the framework supplied in the SDK is for the simulator only and will not link during a device build.
I have tried doing these calls in Objective-C instead, in case it was just the .Type cast that was causing problems, but this does not help. If I access the returned object from Swift, I still get the same error.
I suppose I could create a wrapper in Objective-C that just passes all the calls to the class straight through, but this seems excessive. Is there a more elegant solution to this problem?