简体   繁体   English

找不到iPhone模拟器的SQLite数据库:使用魔术记录

[英]Can't Find iPhone Simulator's SQLite Database : Using Magical Record

In my application's documents folder, I do not find my SQLite database 在我的应用程序的documents文件夹中,找不到我的SQLite数据库

Library/Application Support/iPhone Simulator/6.1/"random app id"/Documents/ 图书馆/应用程序支持/ iPhone模拟器/6.1/“随机应用ID” /文档/

^This folder is empty ^此文件夹为空

MagicalRecord seems to be working, I just have no idea how to find the database. MagicalRecord似乎正在工作,我只是不知道如何查找数据库。

I use the following to set up Magical Record 我使用以下内容来设置Magical Record

[MagicalRecord setupAutoMigratingCoreDataStack];

So where does MagicalRecord store its database? 那么,MagicalRecord在哪里存储其数据库?

MagicalRecord stores, by default, all data stores in the following location: 默认情况下,MagicalRecord将所有数据存储存储在以下位置:

{App Folder}/Library/Application Support/{App Name from Info.plist}/{storeName.sqlite} {App文件夹} /库/应用程序支持/ {来自Info.plist的应用程序名称} / {storeName.sqlite}

This is easily accessible from the simulator as well as documents. 这可以从模拟器以及文档中轻松访问。

您可以使用以下NSPersistentStore MR添加来记录SQlite文件位置:

[NSPersistentStore MR_urlForStoreName:[MagicalRecord defaultStoreName]]

If you know the name of the sqlite file then just do a search in OSX for that file to find the directory. 如果您知道sqlite文件的名称,则只需在OSX中搜索该文件即可找到目录。 Otherwise the file was never created. 否则,将永远不会创建该文件。

Make sure you are setting up the CoreData stack correctly as per the documents . 确保根据文档正确设置CoreData堆栈。

+ (void) setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(NSString *)storeName;

Swift + Xcode 7 + simulator 9.0 Swift + Xcode 7 +模拟器9.0

Please go to your AppDelegate.swift 请转到您的AppDelegate.swift

change 更改

MagicalRecord.setupCoreDataStackWithStoreNamed("yourDBName.sqlite")

to

MagicalRecord.setupCoreDataStackWithAutoMigratingSqliteStoreNamed("yourDBName.sqlite")

Now you can locate the yourDBName.sqlite at /Users/userName/Library/Developer/CoreSimulator/Devices/"random app id"/data/Containers/Data/Application/"random app id"/Library/Application Support/ProjectName 现在,您可以在/ Users / userName / Library / Developer / CoreSimulator / Devices /“ random app id” / data / Containers / Data / Application /“ random app id” / Library / Application Support / ProjectName中找到yourDBName.sqlite

There is a useful tool: simPHolders2 ( http://simpholders.com ) simPHolders easy to access all application folders 有一个有用的工具:simPHolders2( http://simpholders.com )simPHolders易于访问所有应用程序文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM