我正在使用CoreData开发iOS应用程序 .
我从用户那里获得了包含以下隐藏文件的应用程序数据 .
-
Documents / .appname.sqlite.migrationdestination_xxxx(549MB)
-
Documents / .appname.sqlite.migrationdestination_xxxx-shm(721KB)
-
Documents / .appname.sqlite.migrationdestination_xxxx-wal(0Byte)
appname.sqlite,appname.sqlite-wal和appname.sqlite-shm在同一Documents文件夹中 .
appname.sqlite是app的主要sql文件 . 和-wal,-shm似乎是由iOS自动生成的 .
(我从What are the .db-shm and .db-wal extensions in Sqlite databases?学到了)
我认为migrationdestination文件只是迁移的进度数据 .
当用户的设备无法迁移时,它可能仍然存在 . (例如iOS在我的应用程序长时间处于后台时终止我的应用 . )
顺便说一句,一些使用我的应用程序的用户遇到了这个麻烦 .
3月10日13:33:24 xxxx-xx-iPhone XXXXXXXX [5416]:CoreData:错误:(11)致命错误 . /var/mobile/Applications/95D2823D-37E4-4596-9507-B58571D32EBB/Documents/appname.sqlite中的数据库已损坏 . SQLite错误代码:11,'数据库磁盘映像格式错误'
我发现了这个提示 .
Core Data store corruption
答案之一说-wal和-shm会导致此错误 . 所以我删除了它 .
但是,用户仍然会收到相同的错误 . 所以我认为迁移目标可能会导致此错误 .
我会测试它明天删除 . 然后我将结果报告给这里 .
那么有没有人有同样的麻烦,建议,答案?
感谢您阅读我的问题 .
2 回答
这些是迁移期间存在的文件 . 如果您看到这些文件,则迁移失败 . 检查该设备上的崩溃日志并确认 .
您是否在
-applicationDidFinishLaunching...
方法中迁移?你吃的食物是不是很糟糕?这些是导致迁移在迁移过程中失败的常见情况 .最后,我找到了'database disk image is malformed'的解决方案 .
我重命名了这些文件
之前
Documents / .appname.sqlite.migrationdestination_xxxx
Documents / .appname.sqlite.migrationdestination_xxxx-shm
Documents / .appname.sqlite.migrationdestination_xxxx-wal
后
Documents / appname.sqlite
Documents / appname.sqlite-shm
Documents / appname.sqlite-wal
我删除了旧的appname.sqlite,appname.sqlite-shm,appname.sqlite-wal文件 .
我猜到了为什么会发生这种错误 .
也许用户已成功迁移 .
所以有两个sql文件 . appname.sqlite和.appname.sqlite.migrationdestination_xxxx .
然后iOS将交换这些文件,但如果app因某种原因被杀死,appname.sqlite仍然在删除中 .
但app每次都看appname.sqlite,然后iOS猜错了's corrupted, so my app can' t运行 .
现在我要制作这些交换脚本并应用我的应用程序 .
感谢您列出我的问题 .