Core Data轻量级迁移在App更新后崩溃 [英] Core Data lightweight migration crashes after App update

查看:216
本文介绍了Core Data轻量级迁移在App更新后崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两天前我发布了应用程序。根据AppStore的反馈和来自itunesconnect的崩溃报告有很多崩溃发布。但不是100%的用户遭受,只有30%的可能。

Two days ago I released the App. According to feedback on AppStore and crash reports from itunesconnect there are a lot of crashes on launch. But not 100% users suffered, only 30% maybe.

我读过崩溃日志,看到一个问题。它在数据库迁移过程中崩溃。我使用轻量级迁移数据库。
通常我非常仔细地添加新的数据模型版本。即使在每次发布之前,我安装以前的应用程序版本,使用它一段时间,然后我安装最新版本上面它。这是这个时候。

I've read the crash logs and saw a problem. It's crashing on DB migration process. I use lightweight migration of database. Usually I add new datamodel version very carefully. Even before each release I install a previous version of the App, use it for some time and only then I install the latest version above it. So was this time.

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

I looked through two datamodels (previous and present). Were added:

1)新实体(轻量级迁移可以)

2)现有实体中的新字段。它们都是可选的。 (轻量级迁移的确定)

3)现有实体中的一个新字段,我做了可选的和索引。 (OK?)

1) New entities (it's OK for lightweight migration)
2) New fields inside existing entities. All they are optional. (OK for lightweight migration)
3) One new field in existing entity which I made optional AND indexed. (OK?)

没有现有的字段和实体重命名。

None of existing fields and entities were renamed.



我做错了什么?


What I did wrong?


堆栈跟踪:

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:]


推荐答案

这些用户不止一个.xcversion的机会?核心数据不会链接您的升级。所以如果你有V1,V2和V3,V3成为当前版本,V1的任何人都不能升级。可以添加自己的代码,帮助步进V1到V2,然后V2到V3。我相信Marcus Zarra的核心数据书中有示例代码。

Any chance that those users were more than one .xcversion back? Core Data will not "chain" your upgrades for you. So if you have V1, V2, and V3, and V3 becomes the current version, anyone at V1 will not be upgradable. It is possible to add in your own code that helps "step it through" V1 to V2, then V2 to V3. I believe Marcus Zarra's "Core Data" book had example code that does that.

这篇关于Core Data轻量级迁移在App更新后崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆