2015-03-03 105 views
0

我有崩溃的在App Store审核启动,但完全否则工作在设备和模拟器的应用程序。以下是具体细节。应用程序崩溃 - 完美的作品上的设备

该应用为IOS 7写入,并且在IOS 8.x中被测试我象征着来自Apple的崩溃日志,并且它首次尝试访问存储在预填充的Core Data sqlite数据库中的信息。

此代码的数据库副本启动:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator 
{ 
    if (__persistentStoreCoordinator != nil) 
    { 
     return __persistentStoreCoordinator; 
    } 

    NSURL *storeURL = [[self applicationDocumentsDirectory]  URLByAppendingPathComponent:@"CC.sqlite"]; 
    NSArray *paths =  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *storePath = [documentsDirectory  stringByAppendingPathComponent: @"CC.sqlite"]; 

    // Check if the sqlite store exists 
    if (![[NSFileManager defaultManager] fileExistsAtPath:storePath]) { 
     NSLog(@"sqlite db not found... copy into place"); 

     // copy the sqlite files to the store location. 
     NSString *bundleStore = [[NSBundle mainBundle] pathForResource:@"CC" ofType:@"sqlite"]; 
     [[NSFileManager defaultManager] copyItemAtPath:bundleStore  toPath:storePath error:nil]; 

    } 
    else { 
     NSLog(@"Already exists"); 
    } 
    NSError *error = nil; 
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator  alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
    NSDictionary *options = @{ NSSQLitePragmasOption :  @{@"journal_mode" : @"DELETE"} }; 


    if (![__persistentStoreCoordinator  addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL  options:options error:&error]) 
    { 
       NSLog(@"error %@, %@", error, [error userInfo]); 

    } 

    return __persistentStoreCoordinator; 
} 

我们不会在任何问题上运行这几百倍各种iOS设备(由几个不同的人),但总能得到一个启动在苹果崩溃。

从崩溃日志中可以明显看出,应用程序(在应用商店评论期间)试图通过核心数据访问一个不存在的sqlite数据库,但我不知道为什么这只发生在Apple上,而且为什么我不能重现错误。我不确定还有哪些其他信息可以添加到问题中,但可以根据需要快乐地进行更新。

感激地收到任何意见....

+0

他们可以做一个测试,看看你是如何处理的数据库中不存在?也许这是设计。 – 2015-03-03 03:52:24

+0

可能的,但对于完全依赖于db的存在的应用程序...似乎是一个有争议的问题。我不知道在这样的灾难性故障的生产环境.... – jmf1205 2015-03-03 03:57:03

+0

你检查正被提交给苹果,以确认该数据库被包含在捆绑的情况下怎么办? – Paulw11 2015-03-03 05:07:30

回答

0

我会回答这里我自己的问题,但在试图解决这个问题我做了更改代码,使发布的代码不是非常有帮助。

我不得不把启动数据库操作中完成块。这涉及将所有内容移动到我的初始启动视图控制器中,并在数据库初始化时禁用我的标签栏按钮。

发生了什么是正在要求在核心数据SQLite数据库的某些项目,然后才完全预装,因此崩溃。

更多块可以发现here

相关问题