【发布时间】:2016-05-22 17:54:01
【问题描述】:
我有一个插件包,应该加载到我的应用程序中。 当我在 iOS 模拟器上运行应用程序时,捆绑包已正确加载,但是当我重新编译项目以便在我的真实设备上运行应用程序时,我收到以下错误:
Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter): no suitable image found. Did find:
/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter: mmap() error 1 at address=0x022CF000, size=0x00008000 segment=__TEXT in Segment::map() mapping /var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter" UserInfo={NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter, NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedDescription=The bundle “grandmaAdapter” couldn’t be loaded because it is damaged or missing necessary resources., NSDebugDescription=dlopen_preflight(/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter): no suitable image found. Did find:
/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter: mmap() error 1 at address=0x022CF000, size=0x00008000 segment=__TEXT in Segment::map() mapping /var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter, NSBundlePath=/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle}
基本上我做的是:
-定义文档目录中的文件路径
NSString *bundleName = [NSString stringWithFormat:@"%@.bundle", bundle];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
filePath = [documentsDirectory stringByAppendingPathComponent:bundleName];
-然后加载捆绑包
NSBundle *plugin = [[NSBundle alloc] initWithPath:filePath];
NSError *err;
if(![plugin loadAndReturnError:&err]) {
// err contains error info
} else {
// bundle loaded properly
}
这里我得到了上面的错误
有人可以帮我吗?谢谢
已解决
该错误与缺少代码签名有关。 如本文所述:http://ddeville.me/2014/04/dynamic-linking/ 插件需要签名才能在真实设备上加载,使用以下命令:
codesign --sign "iPhone Developer" --force --verbose=4 myPluginName.plugin
【问题讨论】:
-
你是如何将包加载到模拟器中的?如果以编程方式,请显示您的代码。
-
我已经用我的代码编辑了
-
也许问题可能与目录访问权限问题有关?(在真实设备上)。即使消息报告捆绑损坏或丢失数据..
-
这与权限问题无关——我在尝试这个时遇到了同样的错误。我现在不在电脑前,但是今晚我会看我的代码,给你一个明确的答案!
-
提前致谢!