2014-10-06 114 views
1

苹果拒绝我的应用程序与崩溃日志,表明他们已经在iOS 8.0.2的iPhone 6上测试它。我使用相同的iPhone 6和8.0.2测试了我的应用程序,它的工作原理非常完美。我通过iTunesConnect与testflight一起尝试了它,假设这与苹果的测试完全相同 - 显然不是!苹果拒绝 - 无法重现崩溃

有没有人有一个想法,我怎么能解决这个问题(在与审查小组的接触已经有,但他们无法帮助,因为他们说他们没有技术支持,只是测试的应用程序。

我的问题是(从我的角度来看反正怪):它崩溃时,它添加了持久性存储:

 NSError *error = nil; 
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil 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. 

    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: 
    @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES} 

    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 %@, %@", error, [error userInfo]); 
    abort(); 
} 

显然,它崩溃,因为我在那里有abort()声明还,但我不确定该怎么做(即处理该问题 - 只需删除并尝试再次添加商店?)

由于它在我的iPhone上完美运行,我假设它不是源代码中列出的问题之一(如目录,模型等),我是对吗? 我现在正苦苦挣扎几天,任何帮助或想法都不胜感激!

+0

你改变了模型吗?尝试安装旧版本,添加一些数据,然后更新应用程序,也许你有一些数据迁移的问题。 – jcesarmobile 2014-10-06 06:05:29

+0

检查此链接:http://stackoverflow.com/questions/13806849/handling-errors-in-addpersistentstorewithtype – kabarga 2014-10-06 06:10:30

+0

感谢您的意见。我没有改变模型,当我测试它时它工作正常 - 所以我认为这不可能是原因。 – Red 2014-10-06 06:14:43

回答

2

发生这种情况的常见原因是当storeURL中已有文件并且它不符合您指定的模型时。

至于那这里的解决方法是你可以做什么 1)启用轻量级迁移 2)删除现有的文件,然后再试一次

NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @YES, 
          NSInferMappingModelAutomaticallyOption: @YES 
          }; 
BOOL successOfAdding = [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
                    configuration:nil 
                       URL:storeURL 
                      options:options 
                      error:&error] != nil; 
if (successOfAdding == NO) 
{ 
    // Check if the database is there. 
    // If it is there, it most likely means that model has changed significantly. 
    if ([[NSFileManager defaultManager] fileExistsAtPath:storeURL.path]) 
    { 
     // Delete the database 
     [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]; 
     // Trying to add a database to the coordinator again 
     successOfAdding = [_persistentStoreCoordinator addPersistentStoreWithType: NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error] != nil; 
     if (successOfAdding == NO) 
     { 
      NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
      abort(); 
     } 
    } 

而关于拒绝 - 你有你的应用程序的早期版本? 另外,你在哪里试图存储你的数据库?可能有没有访问该路径?

+0

感谢您的评论。它是应用程序的第一个版本,所以没有以前版本的数据库。我将数据库存储在'[[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];'问题是,它适用于我,但不知何故不适用于苹果审查团队 – Red 2014-10-06 10:20:52

+0

另一个问题是,如果 - 无论出于何种原因 - 用户已经更新了数据库,然后出现持久存储的问题,我将删除他的所有数据。 – Red 2014-10-06 10:48:22

+0

原因可能是:除非您有一些用户生成的数据,否则它将被禁止在Documents目录中存储数据库,因为Documents目录的内容可以在设备之间同步。这是不可能的,但在审查访问文档可能被阻止 – hybridcattt 2014-10-06 11:06:04

相关问题