Rumah > Soal Jawab > teks badan
问题描述:
ios9 在运行时通过dlopen()方法加载动态库文件(framework),加载失败,在ios8一下版本程序运行正常。
代码如下:
// 加载应用
NSBundle *appBundle = [NSBundle bundleWithPath:appPath];
NSError *error = nil;
if ([appBundle loadAndReturnError:&error])
{
NSLog(@"bundle load framework success.");
}
else
{
NSLog(@"bundle load framework err:%@",error);
}
失败log:
bundle load framework err:Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx): no suitable image found. Did find:
/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx: mmap() errno=1 validating first page of '/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx'" UserInfo={NSLocalizedRecoverySuggestion=请尝试重新安装软件包。, NSFilePath=/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx, NSLocalizedFailureReason=软件包已损坏或丢失必要的资源。, NSLocalizedDescription=未能载入软件包“xxxx”,因为它已损坏或丢失必要的资源。, NSDebugDescription=dlopen_preflight(/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx): no suitable image found. Did find:
/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx: mmap() errno=1 validating first page of '/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework/xxxx', NSBundlePath=/var/mobile/Containers/Data/Application/F34F9E7A-C129-46F5-A5C6-C82E843F764C/Documents/xxxx.framework}