gpt4 book ai didi

ios - Apple 拒绝 - 无法重现崩溃

转载 作者:行者123 更新时间:2023-11-29 10:37:26 25 4
gpt4 key购买 nike

Apple 拒绝了我的应用程序,崩溃日志表明他们已经在装有 iOS 8.0.2 的 iPhone 6 上测试过它。我用相同的 iPhone 6 和 8.0.2 测试了我的应用程序,它运行完美。我通过 iTunesConnect 使用 testflight 进行了尝试,假设这与 Apple 进行的测试完全相同 - 显然不是!

有没有人知道我该如何解决这个问题(已经与审核团队联系,但他们无能为力,因为他们说他们不是技术支持,只是测试应用程序。

我遇到的问题是(从我的角度来看很奇怪):它在添加持久存储时崩溃:

       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();
}
}

关于拒绝 - 您是否有以前版本的应用程序?另外,您打算在哪里存储数据库?可能无法访问该路径?

关于ios - Apple 拒绝 - 无法重现崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26210703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com