iphone - App 更新后 Core Data 轻量级迁移崩溃

标签 iphone objective-c ios core-data core-data-migration

两天前我发布了应用程序。根据 AppStore 的反馈和 itunesconnect 的崩溃报告,在启动时发生了很多崩溃。但不是 100% 的用户受到影响,可能只有 30%。

我已经阅读了崩溃日志并发现了一个问题。它在数据库迁移过程中崩溃。我使用数据库的轻量级迁移。 通常我会非常小心地添加新的数据模型版本。甚至在每次发布之前,我都会安装以前版本的应用程序,使用它一段时间,然后才安装最新版本。这次也是。

我浏览了两个数据模型(以前的和现在的)。已添加:

1)新增实体(轻量级迁移即可)
2) 现有实体中的新字段。它们都是可选的。 (轻量级迁移OK)
3) 现有实体中的一个新字段,我将其设为可选和索引。 (好吗?)

现有字段和实体均未重命名。


我做错了什么?


堆栈跟踪:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x352f439c pread + 20
1   libsqlite3.dylib                0x30d2d632 unixRead
2   libsqlite3.dylib                0x30d4221a readDbPage
3   libsqlite3.dylib                0x30d41156 sqlite3PagerAcquire
4   libsqlite3.dylib                0x30d583be moveToChild
5   libsqlite3.dylib                0x30d8e0e8 moveToLeftmost
6   libsqlite3.dylib                0x30d59582 sqlite3BtreeNext
7   libsqlite3.dylib                0x30d54328 sqlite3VdbeExec
8   libsqlite3.dylib                0x30d4f6c2 sqlite3_step
9   CoreData                        0x329e8e2e _execute
10  CoreData                        0x329e8d64 -[NSSQLiteConnection execute]
11  CoreData                        0x32a8bd54 -[NSSQLConnection prepareAndExecuteSQLStatement:]
12  CoreData                        0x32add63c -[_NSSQLiteStoreMigrator performMigration:]
13  CoreData                        0x32ad42b8 -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:]
14  CoreData                        0x32a79c02 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:]
15  CoreData                        0x32ac5bf4 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:]
16  CoreData                        0x32ac519c -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:]
17  CoreData                        0x32ac6b58 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:]

最佳答案

这些用户是否有可能返回了不止一个 .xc 版本? Core Data 不会为您“链接”您的升级。因此,如果您有 V1、V2 和 V3,并且 V3 成为当前版本,则 V1 的任何人都无法升级。可以添加您自己的代码,帮助“逐步完成”V1 到 V2,然后从 V2 到 V3。我相信 Marcus Zarra 的“核心数据”一书中有执行此操作的示例代码。

关于iphone - App 更新后 Core Data 轻量级迁移崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9790705/

相关文章:

iphone - if 语句后警报框在模拟器上卡住

iphone - UITableView (Section)Footer 总是最大化宽度

iOS:是否可以创建 NSObjects 矩阵?

objective-c - 如何设置光标处的字体?

ios - 向自定义 Navigation BarButtonItem 添加操作和目标?

iphone - 在标签栏 Controller 的 "more" View 中禁用编辑按钮在 iOS4 中不起作用

iphone - 如何在 iPhone 中的 cell.backgroundview 下面添加图像?

ios - 为什么不同swift类中的函数没有被调用?

iphone - 在 XCode 中链接静态 ObjC 库的过程

objective-c - 如何使 NSView 透明,但保持属于它的对象不变?