Ios 苹果被拒绝-无法复制崩溃

Ios 苹果被拒绝-无法复制崩溃,ios,objective-c,xcode,core-data,crash,Ios,Objective C,Xcode,Core Data,Crash,苹果拒绝了我的应用程序,因为它有一个崩溃日志,表明他们已经在iOS 8.0.2的iPhone6上测试了它。我用同样的iPhone6和8.0.2测试了我的应用程序,效果非常好。我通过iTunesConnect使用testflight进行了测试,假设这与苹果公司的测试完全相同——显然不是 有没有人有什么想法,我如何解决这个问题(已经与审查小组取得联系,但他们无法帮助,因为他们说他们不是技术支持,只是测试应用程序) 我的问题是(从我的角度来看,无论如何都很奇怪):当它添加持久存储时崩溃:

苹果拒绝了我的应用程序,因为它有一个崩溃日志,表明他们已经在iOS 8.0.2的iPhone6上测试了它。我用同样的iPhone6和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上工作得很好,我假设它不是源代码中列出的问题之一(如目录、模型等),对吗?
我已经为此挣扎了好几天,任何帮助或想法都是非常感谢的!!

发生这种情况的常见原因是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();
        }
    }
关于拒绝-你有以前版本的应用程序吗?
另外,您试图将数据库存储在哪里?可能无法访问该路径?

您是否更改了模型?尝试安装旧版本,添加一些数据,然后更新应用程序,可能您在数据迁移方面有问题。请检查此链接:谢谢您的评论。我没有改变模型,在我测试它时它运行良好-所以我认为这不是原因。@kabarga,谢谢链接,听起来是个好主意,但由于我无法重新创建,我需要再次提交给苹果,希望它能工作-或者你有其他想法吗?你可以根据上面的链接修复它,多次检查并删除abort()行。在我们的应用程序中,我们在某些地方仅在调试模式下使用abort。还将选项NSMigratePersistentStoresAutomaticalyOption、NSInFermappingModelAutomaticalyOption设置为YESthanks以供评论。这是该应用程序的第一个版本,因此没有以前版本的数据库。我将数据库存储在
[[NSFileManager defaultManager]URLsForDirectory:NSDocumentDirectory:NSUserDomainMask]lastObject]中
问题是,它对我有效,但对apple review团队不起作用。另一个问题是,如果——无论出于何种原因——用户更新了数据库,然后我发现持久存储有问题,我会删除他的所有数据。原因可能是:除非您有一些用户生成的数据,否则禁止将数据库存储在文档目录中,因为文档目录的内容可以在设备之间同步。这不太可能,但在审查过程中,对文档的访问可能会被阻止。在存储用户数据的情况下,您应该使用轻量级或自定义迁移。用户无法自行更新数据库,只有在您更改模型时才会更新该数据库。在App Store审阅过程中,如果addPersistentStoreWithType出现相同问题,则会更新该数据库。看看你的SO问题,从这一个看来,你已经解决了问题-是纯粹使用这个答案,还是你必须采取任何进一步的步骤?谢谢