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


当前回答

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

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

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

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

其他回答

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

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

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

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

如果有人仍然在lion中遇到这个问题,有一篇很棒的文章提供了19个查看~/Library目录的技巧。在这里找到Dan Frakes的文章http://www.macworld.com/article/161156/2011/07/view_library_folder_in_lion.html

记住模拟器的目录如下所示

~/库/应用程序支持/iPhone模拟器/用户/

看起来Xcode 6.0再次移动了这个位置,至少iOS 8模拟器是这样的。

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

在iOS 5中:

/Users/[用户名]/库/应用程序支持/iPhone模拟器/5.0/应用程序/[AppGUID]/

iOS 8

要找到Documents文件夹,你可以在Documents文件夹中写入一个文件:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent:@"Words.txt"];
NSString *content = @"Apple";
[content writeToFile:fileName atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil];

例如,在didFinishLaunchingWithOptions中。

然后你可以打开一个终端,找到这个文件夹:

$ find ~/Library -name Words.txt