Xcode升级后,核心数据似乎丢失了数据 [英] Core Data Appears to Lose Data After Xcode Upgrade

查看:75
本文介绍了Xcode升级后,核心数据似乎丢失了数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的核心数据应用程序第二次丢失了数据(在下面的说明中)。我不认为这与Xcode的更新有关,但是我今天确实将其更新为9.4(我不记得上次发生此更新是否涉及其中)。我昨天输入了数据,然后关闭了该应用程序,然后重新打开了该应用程序,一切都很好。所有数据都在那里。今天,当我打开应用程序时,没有任何数据。我的应用程序打印出了数据库的位置(print(container.persistentStoreDescriptions)),当我查看sqlite文件时,它的大小为25 kB。

For the second time, my core data app has "lost" (explanation below) the data. I'm not positive this has to do with the update of Xcode, but I did update to 9.4 today (I don't remember whether there was an update involved the last time this happened). I entered data yesterday, then closed the app, re-opened the app, and everything was fine; all the data was there. Today when I opened the app, there was no data. My app prints out the location of the database (print(container.persistentStoreDescriptions)), and when I look at the sqlite file there it has 25 kB.

荒谬的文件夹路径很深,我发现一个文件说它昨天已被修改,当我查看其中的sqlite文件(使用用于SQLite的DB Browser)时,数据就全部存在了(也为25 kB)。似乎Xcode忘记了将数据放在何处。

Searching through the ridiculously deep folder path, I found a file that said it was modified yesterday, and when I look at the sqlite file there (with DB Browser for SQLite), the data is all there (also 25 kB). It seems as if Xcode has forgotten where it put the data. Has anyone else experienced this?

我将如何解决这个问题?我想我可以将SQLite数据库从实际位置复制到Xcode认为的位置(那里的其他文件,.sqlite-shm和.sqlite-wal?)。

How would I go about fixing this? I guess I could copy the SQLite database from where it actually is to the place Xcode thinks it is (the other files there also, .sqlite-shm and .sqlite-wal?).

推荐答案

在更新Xcode之后,最初运行的设备是iPhone 8,而在更新之前我一直在iPad模拟器上运行它

每个模拟器都有自己的文件夹和自己的sqlite文件。因此,如果您想查看iPad模拟器之前的数据,则需要从新的Xcode运行相同的iPad模拟器。如果将sqlite文件从一个模拟器文件夹复制到另一个模拟器文件夹,请确保也复制-shm和-wal文件。

Each simulator gets its own folder with its own sqlite files. So if you want to see the data that was in the iPad simulator before, you need to run the same iPad simulator from the new Xcode. If you copy sqlite files from one simulator folder to another, be sure to copy the -shm and -wal files too.

这篇关于Xcode升级后,核心数据似乎丢失了数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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