As the title says... I'm interested in dlopen(). I understand this isn't allowed by the app store but I'm curious about this on iOS.
The issue I have is that I can create a .dylib file and I can load this file at runtime with the following code
char *dylibPath = "/Applications/myapp.app/mydylib2.dylib";
void *libHandle = dlopen(dylibPath, RTLD_NOW);
if (libHandle != NULL) {
NSString * (*someMethod)() = dlsym(libHandle, "someMethod");
if (someMethod != NULL) {
NSLog(someMethod());
}
dlclose(libHandle);
}
This is taken from here.
The problem I have is that if I change mydylib2.dylib, dlopen doesn't load the recompiled .dylib file. Instead, it resolves an old version of the function someMethod.
For example, if someMethod first returns @"Hello" and I change this to be @"Hello World" and recompile, the code above will always return @"Hello" until I restart the app in the simulator.
Do any know why this is the case? and suggest a workaround so the this .dylib can be reloaded at runtime?