dlopen for dylib,.framework

时间:2016-04-06 14:39:49

标签: ios dylib

我正在为企业应用做,我正在研究dlopen,因为我需要下载代码并在运行时运行。 (像子模块)。

Calling dlopen on ios

Download and execute iOS code dynamically at runtime

我开始对此感到困惑,因为有些打开.dylib和一些打开的.framework。

我尝试从资源目录加载,hModule总是为零。

NSString *dlPath = @"StaticLibrary.dylib";//i try with complete path and it is not okay also

const char* cdlpath = [dlPath UTF8String];
void* hModule = dlopen(cdlpath, RTLD_LAZY);

我从网址下载并尝试这样做。

    const char *cString = [filePath cStringUsingEncoding:NSASCIIStringEncoding];

    void *uikit = dlopen(cString, RTLD_GLOBAL);
    id (*FunctionName)() = dlsym(uikit, "helloWorldFromStaticLibrary");
    FunctionName();
    dlclose(uikit);
    //my cString is "/Users/khantthulinn/Library/Developer/CoreSimulator/Devices/04F2B44A-B78E-4400-98B7-EF6AA8352646/data/Containers/Data/Application/63E7D709-F140-4AF1-A4F5-475454B347FE/Library/Caches/StaticLibrary.dylib"

我只是不知道为什么我的dlopen总是为零。 stackoverflow中的一些人说我需要签署相同的证书。我也试过了。但这不好。我该怎么办?

0 个答案:

没有答案