2013-10-18 70 views
1

我在iPad应用程序中遇到了一个非常奇怪的行为。我创建了几个捆绑包,应用程序将它们下载并保存到文档目录中。NSBundle加载崩溃发布

我有一个自定义的捆绑管理器,我可以加载这样的捆绑包。

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 

NSString *bundlePath; 
if (![bundleName hasSuffix:@".bundle"]) { 
    bundlePath = [documentsDirectory stringByAppendingFormat:@"/%@.bundle", bundleName]; 
} else { 
    bundlePath = [documentsDirectory stringByAppendingFormat:@"/%@", bundleName]; 
} 
NSBundle *bundle = nil; 
NSError *error = nil; 

bundle = [[NSBundle alloc] initWithPath:bundlePath]; 
if (!bundle) { 
    return nil; 
} 
[bundle loadAndReturnError:&error]; 

在调试模式下,所有代码都像魅力一样工作。该软件包被加载并且可以在应用程序中使用该内容。捆绑包含图像和笔尖,无代码。在我设置的套装版本设置中,我设置了COMBINE_HIDPI_IMAGESNO,以便图像不会被组合为tiff图像。这些软件包也不包含任何代码。

那么问题是什么。那么,当启动应用程序没有调试(没有连接到Xcode)应用程序崩溃,并生成此错误消息。 [bundle loadAndReturnError:&错误]是代码崩溃的地方。

Exception Type: EXC_CRASH (SIGKILL) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 
Crashed Thread: 0 

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 dyld       0x2fe8e2d8 strcmp + 0 
1 dyld       0x2fe83aac ImageLoaderMachO::parseLoadCmds() + 56 
2 dyld       0x2fe88d30 ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, ImageLoader::LinkContext const&) + 296 
3 dyld       0x2fe839c6 ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 222 
4 dyld       0x2fe7b0d4 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 664 
5 dyld       0x2fe7e774 dyld::loadPhase5stat(char const*, dyld::LoadContext const&, stat*, int*, bool*, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 428 
6 dyld       0x2fe7e498 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 248 
7 dyld       0x2fe7e37c dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 128 
8 dyld       0x2fe7e29c dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 984 
9 dyld       0x2fe7dc36 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 110 
10 dyld       0x2fe7ada4 dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 168 
11 dyld       0x2fe7ab58 dyld::load(char const*, dyld::LoadContext const&) + 208 
12 dyld       0x2fe7f8da dlopen + 802 
13 libdyld.dylib     0x39dee946 dlopen + 46 
14 CoreFoundation     0x31ab4910 _CFBundleDlfcnLoadBundle + 128 
15 CoreFoundation     0x31ab478c _CFBundleLoadExecutableAndReturnError + 356 
16 Foundation      0x323d2154 -[NSBundle loadAndReturnError:] + 844 
17 Visitor Self Service   0x000e251a -[CoreBundleManager bundleForName:] (CoreBundleManager.m:70) 
18 Visitor Self Service   0x000cd418 -[CoreProcessDefinition processBundle] (CoreProcessDefinition.m:226) 
19 Visitor Self Service   0x000cf17e -[CoreProcessRuntime loadControllerForStep:] (CoreProcessRuntime.m:187) 
20 Visitor Self Service   0x000ce9f4 -[CoreProcessRuntime performNextStepInProcessDefinition] (CoreProcessRuntime.m:112) 
21 Visitor Self Service   0x000ba642 __62-[DynamicViewController prepareControllerForProcessDefinition]_block_invoke (DynamicViewController.m:107) 
22 libdispatch.dylib    0x39ddb790 _dispatch_call_block_and_release + 8 
23 libdispatch.dylib    0x39dde8be _dispatch_after_timer_callback + 10 
24 libdispatch.dylib    0x39ddb5d8 _dispatch_client_callout + 20 
25 libdispatch.dylib    0x39ddc48a _dispatch_source_invoke + 254 
26 libdispatch.dylib    0x39ddee04 _dispatch_main_queue_callback_4CF + 164 
27 CoreFoundation     0x31afb1ac __CFRunLoopRun + 1284 
28 CoreFoundation     0x31a6e238 CFRunLoopRunSpecific + 352 
29 CoreFoundation     0x31a6e0c4 CFRunLoopRunInMode + 100 
30 GraphicsServices    0x35629336 GSEventRunModal + 70 
31 UIKit       0x3398a2b4 UIApplicationMain + 1116 
32 Visitor Self Service   0x000b66d8 main (main.m:16) 
33 libdyld.dylib     0x39deeb1c start + 0 

回答

2

最后我得到它的工作。

有几个步骤来设置一个合适的包。

在项目生成设置为包设置

  • 架构=>的ARMv7,armv7s
  • 支持Plattforms =>的iOS
  • 有效架构=>的ARMv7,armv7s
  • 设置一个有效代码标识标识
  • 设置匹配的配置文件

您还需要一个Info.plist的

  • 所需的设备能力=> ARMv7的,armv7s
  • 主体类=>你的包主体类名
  • 可执行文件=>同委托人类

注意

外部代码执行是由Apple Review Guidelines禁止,所以它只能在内部应用程序中使用。

2.7 Apps that download code in any way or form will be rejected

2.8 Apps that install or launch other executable code will be rejected

+0

这是什么意思? “设置一个有效的代码标识标识; 设置一个匹配的配置文件”您能举一个包的例子吗? – Padavan