First of all I'm trying to execute code in my app (only from my Swift Framework!) when it is loaded into memory.
Normally I would use this ObjC Method to execute Code when my Framework is loaded into Memory.
Is there something equivalent to this in Swift?
static void __attribute__((constructor)) initialize(void){
NSLog(@"==== Code Injection in Action====");
/*
My Code
*/
}
What I have found:
Apple Developer Page regarding this (but it's also only explained in ObjC)
Other Page about Code Injection in general
Any Ideas?
Currently, Swift does not have this functionality. You can either just define an initialization function for your framework and ask your clients to call it before using any other APIs, or you can just mix in an Objective-C file into the project.