2012-03-10 149 views
2

我最近通过iTunes Connect将我的应用程序提交给Apple,现在它已经在iTunes商店中。但是,当我将它下载到朋友的iPhone上时,它立即崩溃。我在iPhone模拟器和iPad上测试了它(我没有iPhone)。所以,我插在iPhone进入我的电脑,并得到了它这个崩溃日志:iPhone上的奇怪应用程序崩溃 - 未被Apple拒绝

  Incident Identifier: 893F48B6-9805-4BF7-BA84-D5CDF85392E8 
    CrashReporter Key: 72f4227f4240642bb75dcb75873b6f4b42cf3cf7 
    Hardware Model:  iPhone3,1 
    Process:   App [305] 
    Path:   /var/mobile/Applications/4A493313-CB6D-422D-8098-BB2DE94A30B2/-----.app/----- 
    Identifier:  App 
    Version:   ??? (???) 
    Code Type:  ARM (Native) 
    Parent Process: launchd [1] 

    Date/Time:  2012-03-10 13:40:30.841 -0700 
    OS Version:  iPhone OS 5.0.1 (9A405) 
    Report Version: 104 

    Exception Type: EXC_CRASH (SIGABRT) 
    Exception Codes: 0x00000000, 0x00000000 
    Crashed Thread: 0 

    Thread 0 name: Dispatch queue: com.apple.main-thread 
    Thread 0 Crashed: 
    0 libsystem_kernel.dylib   0x35d7732c 0x35d66000 + 70444 
    1 libsystem_c.dylib    0x32c40f54 0x32bf3000 + 319316 
    2 libsystem_c.dylib    0x32c39fe4 0x32bf3000 + 290788 
    3 GraphicsServices    0x30637444 0x30633000 + 17476 
    4 GraphicsServices    0x30637e84 0x30633000 + 20100 
    5 UIKit       0x37233520 0x37202000 + 202016 
    6 App        0x000104d0 main (main.m:14) 
    7 App        0x00010488 start + 32 

    Thread 1 name: Dispatch queue: com.apple.libdispatch-manager 
    Thread 1: 
    0 libsystem_kernel.dylib   0x35d673b4 0x35d66000 + 5044 
    1 libdispatch.dylib    0x36a91e78 0x36a85000 + 52856 
    2 libdispatch.dylib    0x36a91b96 0x36a85000 + 52118 

    Thread 2: 
    0 libsystem_kernel.dylib   0x35d77cd4 0x35d66000 + 72916 
    1 libsystem_c.dylib    0x32bfd30a 0x32bf3000 + 41738 
    2 libsystem_c.dylib    0x32bfd09c 0x32bf3000 + 41116 

    Thread 3: 
    0 libsystem_kernel.dylib   0x35d77cd4 0x35d66000 + 72916 
    1 libsystem_c.dylib    0x32bfd30a 0x32bf3000 + 41738 
    2 libsystem_c.dylib    0x32bfd09c 0x32bf3000 + 41116 

    Thread 4 name: WebThread 
    Thread 4: 
    0 libsystem_kernel.dylib   0x35d67010 0x35d66000 + 4112 
    1 libsystem_kernel.dylib   0x35d67206 0x35d66000 + 4614 
    2 CoreFoundation     0x33e3041c 0x33da3000 + 578588 
    3 CoreFoundation     0x33e2f154 0x33da3000 + 573780 
    4 CoreFoundation     0x33db24d6 0x33da3000 + 62678 
    5 CoreFoundation     0x33db239e 0x33da3000 + 62366 
    6 WebCore       0x36286128 0x361de000 + 688424 
    7 libsystem_c.dylib    0x32c02c16 0x32bf3000 + 64534 
    8 libsystem_c.dylib    0x32c02ad0 0x32bf3000 + 64208 

    Thread 0 crashed with ARM Thread State: 
     r0: 0x00000000 r1: 0x00000000  r2: 0x00000001  r3: 0x00000000 
     r4: 0x00000006 r5: 0x3e52ace8  r6: 0x3f28dfe0  r7: 0x2fe0dc84 
     r8: 0x2fe0dd60 r9: 0x0012ca70  r10: 0x00000001  r11: 0x00000000 
     ip: 0x00000148 sp: 0x2fe0dc78  lr: 0x32c40f5b  pc: 0x35d7732c 
     cpsr: 0x00000010 

接下来,我删除了原来的应用程序,并把它放在iPhone通过的Xcode 4,我试图运行这种方式,它坠毁与此错误:

2012-03-09 22:05:23.980 App[15930:707] Unresolved error in persistentStoreCoordinator Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x199a10 {URL=file://localhost/var/mobile/Applications/B7B2F695-B599-40A3-8D5A-88E1B7E1C148/Documents/App.sqlite, metadata=<CFBasicHash 0x17a8a0 [0x3ef4c630]>{type = immutable dict, count = 7, 
entries => 
    2 : <CFString 0x17eb10 [0x3ef4c630]>{contents = "NSStoreModelVersionIdentifiers"} = <CFArray 0x17ec10 [0x3ef4c630]>{type = immutable, count = 1, values = (
    0 : <CFString 0x3ef409d0 [0x3ef4c630]>{contents = ""} 
)} 
    4 : <CFString 0x17eb40 [0x3ef4c630]>{contents = "NSPersistenceFrameworkVersion"} = <CFNumber 0x1796d0 [0x3ef4c630]>{value = +386, type = kCFNumberSInt64Type} 
    6 : <CFString 0x17eb70 [0x3ef4c630]>{contents = "NSStoreModelVersionHashes"} = <CFBasicHash 0x17ece0 [0x3ef4c630]>{type = immutable dict, count = 2, 
entries => 
    1 : <CFString 0x3ef3df50 [0x3ef4c630]>{contents = "Camera"} = <CFData 0x17ec40 [0x3ef4c630]>{length = 32, capacity = 32, bytes = 0x497312a7c61a2dc8fe30e74ecc001ebc ... 1b5a15fa47a27413} 
    2 : <CFString 0x17ec30 [0x3ef4c630]>{contents = "Team"} = <CFData 0x17ec90 [0x3ef4c630]>{length = 32, capacity = 32, bytes = 0x401bd3f39f173666c4b24d43944d2562 ... 35b2b372c7051eed} 
} 

    7 : <CFString 0x3ea9cf40 [0x3ef4c630]>{contents = "NSStoreUUID"} = <CFString 0x17e800 [0x3ef4c630]>{contents = "44E18608-E974-4E3D-A4F0-EB7C836869B4"} 
    8 : <CFString 0x3ea9cde0 [0x3ef4c630]>{contents = "NSStoreType"} = <CFString 0x3ea9cdf0 [0x3ef4c630]>{contents = "SQLite"} 
    9 : <CFString 0x17ebc0 [0x3ef4c630]>{contents = "_NSAutoVacuumLevel"} = <CFString 0x17ed40 [0x3ef4c630]>{contents = "2"} 
    10 : <CFString 0x17ebe0 [0x3ef4c630]>{contents = "NSStoreModelVersionHashesVersion"} = <CFNumber 0x157050 [0x3ef4c630]>{value = +3, type = kCFNumberSInt32Type} 
} 
, reason=Can't find model for source store}, { 
URL = "file://localhost/var/mobile/Applications/B7B2F695-B599-40A3-8D5A-88E1B7E1C148/Documents/App.sqlite"; 
metadata =  { 
NSPersistenceFrameworkVersion = 386; 
NSStoreModelVersionHashes =  { 
Camera = <497312a7 c61a2dc8 fe30e74e cc001ebc 6282715c 1751f100 1b5a15fa 47a27413>; 
Team = <401bd3f3 9f173666 c4b24d43 944d2562 a3a17942 4bd878d0 35b2b372 c7051eed>; 
}; 
NSStoreModelVersionHashesVersion = 3; 
NSStoreModelVersionIdentifiers =  (
"" 
); 
NSStoreType = SQLite; 
NSStoreUUID = "44E18608-E974-4E3D-A4F0-EB7C836869B4"; 
"_NSAutoVacuumLevel" = 2; 
}; 
reason = "Can't find model for source store"; 
} 

我试图替换字符串pathForResource在下面的方法与我最近的商店(Appv4)的确切名称,但它告诉我,该数据库的路径为空。

- (NSManagedObjectModel *)managedObjectModel { 

    if (managedObjectModel_ != nil) { 
     return managedObjectModel_; 
    } 
    NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"App" ofType:@"momd"]; 
    NSURL *modelURL = [NSURL fileURLWithPath:modelPath]; 
    managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];  
    return managedObjectModel_; 
} 

在尝试通过xcode在iPhone上多次运行应用程序后,它突然开始工作。但是,应用商店中的版本不会发生同样的情况。

请帮忙!我无法弄清楚什么是错的。

编辑:这是我的AppDelegate.m文件

#import "AppAppDelegate.h" 
#import "RootViewController.h" 

@implementation AppAppDelegate 

@synthesize window; 
@synthesize navigationController; 
//@synthesize managedObjectModel_, managedObjectContext_; 


#pragma mark - 
#pragma mark Application lifecycle 

- (void)awakeFromNib {  

    RootViewController *rootViewController = (RootViewController *)[navigationController topViewController]; 
    rootViewController.managedObjectContext = self.managedObjectContext; 
} 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 

    // Add the navigation controller's view to the window and display. 
    [self.window addSubview:navigationController.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 


- (void)applicationWillResignActive:(UIApplication *)application { 
    } 


- (void)applicationDidEnterBackground:(UIApplication *)application { 
     [self saveContext]; 
} 


- (void)applicationWillEnterForeground:(UIApplication *)application { 
    } 


- (void)applicationDidBecomeActive:(UIApplication *)application { 

} 


/** 
applicationWillTerminate: saves changes in the application's managed object context before the application terminates. 
*/ 
- (void)applicationWillTerminate:(UIApplication *)application { 
    [self saveContext]; 
} 


- (void)saveContext { 

    NSError *error = nil; 
    NSManagedObjectContext *managedObjectContext = self.managedObjectContext; 
    if (managedObjectContext != nil) { 
     if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { 

      /* 
      Replace this implementation with code to handle the error appropriately. 

      abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button. 
      */ 
      NSLog(@"Unresolved error in saveContext %@, %@", error, [error userInfo]); 
      abort(); 
     } 
    } 
}  


#pragma mark - 
#pragma mark Core Data stack 

/** 
Returns the managed object context for the application. 
If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. 
*/ 
- (NSManagedObjectContext *)managedObjectContext { 

    if (managedObjectContext_ != nil) { 
     return managedObjectContext_; 
    } 

    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 
    if (coordinator != nil) { 
     managedObjectContext_ = [[NSManagedObjectContext alloc] init]; 
     [managedObjectContext_ setPersistentStoreCoordinator:coordinator]; 
    } 
    return managedObjectContext_; 
} 


/** 
Returns the managed object model for the application. 
If the model doesn't already exist, it is created from the application's model. 
*/ 
- (NSManagedObjectModel *)managedObjectModel { 

    if (managedObjectModel_ != nil) { 
     return managedObjectModel_; 
    } 
    NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"App" ofType:@"momd"]; 
    NSURL *modelURL = [NSURL fileURLWithPath:modelPath]; 
    managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];  
    return managedObjectModel_; 
} 


/* 
Returns the persistent store coordinator for the application. 
If the coordinator doesn't already exist, it is created and the application's store added to it. 
*/ 
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { 

    if (persistentStoreCoordinator_ != nil) { 
     return persistentStoreCoordinator_; 
    } 

    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"App.sqlite"]; 

    NSError *error = nil; 
//Auto update?  

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 
    // 

    persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
    if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) { 
     /* 
     Replace this implementation with code to handle the error appropriately. 

     abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button. 

     Typical reasons for an error here include: 
     * The persistent store is not accessible; 
     * The schema for the persistent store is incompatible with current managed object model. 
     Check the error message to determine what the actual problem was. 


     If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory. 

     If you encounter schema incompatibility errors during development, you can reduce their frequency by: 
     * Simply deleting the existing store: 
     [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil] 

     * Performing automatic lightweight migration by passing the following dictionary as the options parameter: 
     [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 

     Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details. 

     */ 
     NSLog(@"Unresolved error in persistentStoreCoordinator %@, %@", error, [error userInfo]); 
     abort(); 
    }  

    return persistentStoreCoordinator_; 
} 


#pragma mark - 
#pragma mark Application's Documents directory 

/** 
Returns the URL to the application's Documents directory. 
*/ 
- (NSURL *)applicationDocumentsDirectory { 
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 
} 


#pragma mark - 
#pragma mark Memory management 

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 
    /* 
    Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 
    */ 
} 


- (void)dealloc { 

    [managedObjectContext_ release]; 
    [managedObjectModel_ release]; 
    [persistentStoreCoordinator_ release]; 

    [navigationController release]; 
    [window release]; 
    [super dealloc]; 
} 


@end 
+3

有一个开发者账户,你每年有一次免费门票让代码审查由苹果公司完成,他们帮助您找到并消除错误。没有看到你的整个应用程序,并得到你想要做什么的详细描述,这是很难消除的错误 – klaustopher 2012-03-10 21:32:52

+0

如果你愿意看看我的代码,你需要看什么? AppDelegate文件? – Egdod 2012-03-10 21:35:24

回答

3

你可以试试这个:Can’t find model for source store。根据作者说,“无法找到源存储模型”意味着您的对象模型和生成/编码的模型代码不同步,或者您的数据库未正确迁移/升级到新版本。“他建议使用此代码:

NSDictionary *optionsForSTore = [NSDictionary dictionaryWithObjectsAndKeys: 

[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 

[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 
+0

感谢您的快速回复,但不幸的是,我已在添加此应用程序之前将其提交给应用程序商店。 – Egdod 2012-03-10 21:37:25

+0

请问这个问题:http://stackoverflow.com/a/4536668/535632有帮助吗? – 2012-03-10 21:50:49

+0

那么,你最后的评论发送给我一个相当有趣的寻找答案。它质疑你与我联系,绝对帮助我更好地理解数据迁移的工作原理。但是,根据问题的答案,我发现应用程序没有问题,但我的应用程序突然开始工作,原因不明。我相当肯定我没有改变任何东西,但它现在起作用了:\。我将把它作为应用商店的更新提交,并查看我的问题是否已解决。谢谢! – Egdod 2012-03-10 23:22:04