我正在使用
dlsym
要加载私有API(iOS 9.3要求):
handle = dlopen(CORETELPATH, RTLD_LAZY);
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
当我关闭应用程序(在多任务模式下从底部滑动)并重新启动应用程序时,它会在第二行崩溃。
这个
handle
等于
NULL
我没有成功加载两次库。
我试图用
dlerror()
,但它也会返回
无效的
.
有人知道这个问题吗?如何解决?
编辑:
这是完整的代码;使用
if (handle != NULL)
应用程序不会崩溃,但私有框架也不会加载
#define CORETELPATH "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"
handle = dlopen(CORETELPATH, RTLD_LAZY);
NSLog(@"DL Error : %s", dlerror());
if (handle != NULL) {
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
CTResultConnection = _CTServerConnectionCreate(NULL, simMonitorCallback, NULL);
_CTServerConnectionAddToRunLoop = dlsym(handle, "_CTServerConnectionAddToRunLoop");
_CTServerConnectionAddToRunLoop(CTResultConnection, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
_CTServerConnectionRegisterForNotification = dlsym(handle, "_CTServerConnectionRegisterForNotification");
_CTServerConnectionUnregisterForNotification = dlsym(handle, "_CTServerConnectionUnregisterForNotification");
_CTServerConnectionRegisterForNotification(CTResultConnection, kCTSIMSupportSIMStatusChangeNotification);
_CTServerConnectionGetSIMStatus = dlsym(handle, "_CTServerConnectionGetSIMStatus");
_CTServerConnectionCopyMobileEquipmentInfo = dlsym(handle, "_CTServerConnectionCopyMobileEquipmentInfo");
}