Skip to content

Instantly share code, notes, and snippets.

@zhaorui
Created February 5, 2018 03:53
Show Gist options
  • Save zhaorui/49b9f6e2bcd3790b2f5ae13d96104148 to your computer and use it in GitHub Desktop.
Save zhaorui/49b9f6e2bcd3790b2f5ae13d96104148 to your computer and use it in GitHub Desktop.
NSString *dylibPath = @"/Users/billzhao/Desktop/libRulesActions.dylib";
const char *libPath = [dylibPath cStringUsingEncoding:NSUTF8StringEncoding];
void *dl = dlopen(libPath, RTLD_NOW);
const char *dlErr = dlerror();
if (dlErr) {
NSLog(@"dlerror() = %s", dlErr);
} else {
NSLog(@"dylib path is %s, dl = %p", libPath, dl);
}
// Get the Person class (required with runtime-loaded libraries).
Class RulesActions_class = objc_getClass("RulesActions");
if (!RulesActions_class) {
NSLog(@"[%s] main: Unable to get RulesActions_class class", __FILE__);
exit(EXIT_FAILURE);
}
// Create an instance of Person.
NSLog(@"[%s] main: Instantiating RulesActions_class", __FILE__);
RulesActions* person = [[RulesActions_class alloc] init];
NSLog(@"%@", person);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment