Where Does Simulator 8.0 Store Files

2019-01-23 04:21发布

问题:

I cannot find the directory for the new simulator data in Xcode-6 Beta for IOS 8

It is not in ~/Library/Application Support/IPhone Simulator/

Where does the iPhone Simulator store its data?

回答1:

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.



回答2:

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/



回答3:

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


回答4:

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.



回答5:

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


回答6:

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!



回答7:

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
...