Create iOS 6.1 Dynamic Library and Link

I am trying to create a dynamic library for iOS and load it at runtime. Having examined this question and this answer , I am doing this using iOSOpenDev and deploying everything to my iPhone. The xcode project for dylib is called KDylibTwo, and the files I are modiefied:

KDylibTwo.h

#import <Foundation/Foundation.h>

@interface KDylibTwo : NSObject
-(void)run;
@end

KDylibTwo.m

#import "KDylibTwo.h"

@implementation KDylibTwo

-(id)init
{
    if ((self = [super init]))
    {
    }

    return self;
}

-(void)run{
    NSLog(@"KDylibTwo loadded.");
}

@end

To check if my library is working, after creating it for profiling (the way iOSOpenDev deploys it to the iPhone), I can find it on my device in /usr/lib/libKDylibTwo.dyliband build the setting (again using iOSOpenDev) by connecting SpringBoard as follows:

#include <dlfcn.h>

%hook SBApplicationIcon

-(void)launch{
    NSLog(@"\n\n\n\n\n\n\nSBHook For libKDylibTwo.dylib");

    void* dylibLink = dlopen("/usr/lib/libKDylibTwo.dylib", RTLD_NOW);

    if(dylibLink == NULL) {
        NSLog(@"Loading failed.");
    } else {
        NSLog(@"Dylib loaded.");

        void (*function)(void);
        *(void **)(&function) = dlsym(dylibLink, "run");
        if (function) {
            NSLog(@"Function found.");
            (*function)();
        } else {
            NSLog(@"Function NOT found");
        }
    }

    NSLog(@"End of code");
    %log;
    %orig;
}

%end

( ), :

Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: SBHook For libKDylibTwo.dylib
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: Dylib loaded.
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: Function NOT found
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: End of code
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: -[<SBApplicationIcon: 0x1d5008c0> launch]

, , ! , , -, App Store, , , , !

,
.

+3
2

, "dlsym" - C. objective-C dylib, , objc. :

void* dylibLink = dlopen("/usr/lib/libKDylibTwo.dylib", RTLD_NOW);
id KDylibTwo = [[objc_getClass("KDylibTwo") alloc] init];
[KDylibTwo run];

. .

KDylibTwo. objc_getClass , , objective-C, alloc init. objc_getClass, , . , .

run. , objective-C. , . , .

+6

dlsym, c ( , c dlsym, ).

, dlsym .

"run" C. - :

EXPORT void run()
{
 NSLog(@"Run");
}

Object C , , , , dlsym .

+2

All Articles