Where Does Simulator 8.0 Store Files

别来无恙 提交于 2019-11-28 23:15:23

Something like this:

/Users/{YOUR NAME}/Library/Developer/CoreSimulator/Devices/{DEVICE ID}/data/Containers/Data/Application/{APPLICATION ID}/

The Device ID can be a bit hard to find (basically, there's one folder with a random-looking name for each simulator you have). To get to the correct folder, I used this terminal command:

find ~ -name myFile.txt

Where myFile.txt was one of the files in my application. The terminal then printed out the full location—this might be more useful to you then checking each one-by-one, if you have a file (or, can make one) that you can search for.

In XCode 6 it's really hard to find out. But I do this in the simple way:

With XCode opened just write this in Debug Area:

po [NSBundle mainBundle]

Or logging:

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

The result is something like that:

After that you can open Terminal app and go to path with this command:

open yourAppPath...


[Update]

I found an amazing app to do this: http://simpholders.com/

To locate the Documents folder of an app in iOS 8 Simulator, you can first write a file in the Documents folder:

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];

say, in didFinishLaunchingWithOptions.

Then you can open a Terminal and find the folder:

$ find ~/Library -name Words.txt

Ok, I was frustrated trying to find things manually. Ill keep my notes above to show what does NOT seem to work.

What DOES work, and is a great relief to me, is SimPHolders. Google it. Download it. Run it. Enjoy.

Simulators directory in XCode6 is moved to:

Library ▸ Developer ▸ CoreSimulator

Full Path to Application folder:

~/ ▸ Library ▸ Developer ▸ CoreSimulator ▸ Devices ▸ 5D71993D-78C2-49F4-9B30-99D0307D3A2F ▸ data ▸ Containers ▸ Data ▸ Application ▸ AE50273B-993C-45DA-97E8-3F88E4B64BDE ▸ Documents ▸ xyz.sqlite

With the simulator open, go to Hardware->Devices->Manage Devices.

A Window shows, outlining each of the simulators available, and the Unique Identifier that goes with each one.

Therefore, after you have navigated in Finder to ~Library/Developer/CoreSimulator as others describe above, you can tell which of the directories therein contains the simulator you want, by looking for the Unique Identifier.

Once inside there, you still need to drill down further... in my case I found I had to navigate into data/Containers/Data/Application, then look for the folder inside that had todays date.

Finally! I arrived at my familiar Documents and Library folders.

Thanks Apple once again, for keeping us iOS developers gainfully employed!

You can add NSLogs in application delegate "didFinishLaunchingWithOptions" method, so they print your paths

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if TARGET_IPHONE_SIMULATOR
    NSLog(@"APP BUNDLE :: %@", [NSBundle mainBundle]);
    NSLog(@"APP DOCUMENTS :: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
#endif
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!