我有一个SQLite数据库,我用它来存储应用程序数据,我可以查看它内部以调试我遇到的问题-但是iPhone模拟器通常在哪里存储它的数据?


当前回答

对于Xcode 4.6,它被存储在以下路径…

/Users/[currentuser]/Library/Application Support/iPhone Simulator/6.1/Applications/

要通过编程方式了解它,请使用以下代码

  NSLog(@"path:%@",[[NSBundle mainBundle]bundlePath]);

其他回答

对于不经常使用Xcode的react原生用户,你可以使用find。打开终端,通过数据库名称进行搜索。

$ find ~/Library/Developer -name 'myname.db'

如果你不知道确切的名称,你可以使用通配符:

$ find ~/库/开发人员名'myname.*'

在Xcode 5中,你可以使用以下代码:

#import <Foundation/NSFileManager.h>

and:

NSString *homeDir = NSHomeDirectory();
NSLog(@"%@",homeDir);

结果看起来像这样:

"/Users/<your user name>/Library/Application Support/iPhone Simulator/7.1/Applications/hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh"

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh是一个十六进制字符串,用来识别你的iOS应用程序。

发现:

~/Library/Application Support/iPhone Simulator/User/

为Xcode6 - iOS8 +

~ /图书馆/开发/ CoreSimulator /设备/[的DeviceID] /数据/集装箱/数据/应用程序/ [AppID] /

接受的答案对于SDK 3.2是正确的- SDK 4用它可以模拟的每个遗留的iPhone OS/iOS版本的数字替换该路径中的/User文件夹,因此路径变成:

~/Library/Application Support/iPhone Simulator/[OS version]/Applications/[appGUID]/

如果你安装了之前的SDK,它是3.1。X模拟器将继续将其数据保存在:

~/Library/Application Support/iPhone Simulator/User/Applications/[appGUID]/

在Lion上,Users/[username]/Library被隐藏。

要在Finder中查看,单击屏幕顶部的“Go”菜单,并按住“alt”键显示“Library”。

点击“Library”,你可以看到之前隐藏的库文件夹。

先前的建议:

Use

chflags nohidden /users/[username]/library

在终端中显示文件夹。