Reputation: 23550
When running an app onto the simulator, it creates a folder onto the Mac to contain the apps datas in a "Documents" folder. This folder is changed when you delete the app from the simulator, or when you change some app settings into XCode. When you have dozens of apps, it's a nightmare to find the good one by hand.
Is there a way to easily access this folder ?
Upvotes: 4
Views: 7601
Reputation: 1439
Bazinga's answer (along with sebrenner's deprecation notice) is great for Objective-C.
For Swift, the equivalent would be:
let appFolderPath = NSBundle.mainBundle().resourcePath
let fileManager = NSFileManager.defaultManager()
print("App Directory is: \(appFolderPath)")
print("Directory Contents:\n \(fileManager.contentsAtPath(appFolderPath!))")
Upvotes: 0
Reputation: 83
directoryContentsAtPath: is deprecated.
Instead use contentsOfDirectoryAtPath:error:
//App Directory & Directory Contents
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager contentsOfDirectoryAtPath:appFolderPath error:nil]);
Upvotes: 0
Reputation: 4917
The location in general is:
/Users/yourusername/Library/Application Support/iPhone Simulator/7.1/Applications/appcode/Documents/yourdocuments.db
'yourusername': username you used for your development machine
'appcode': application identifier that is a series of numbers such as: 32F88907-B348-4764-9819-A5B6F9169FB7 (unique to your app)
the version number (7.1) in the path depends on the version of Xcode and hence the simulator.
Upvotes: 0
Reputation: 2466
Just gonna try answering. How about logging it, like this:
//App Directory & Directory Contents
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]);
Upvotes: 6
Reputation: 18517
What I do is create a link in the Finder sidebar to the simulator folder. It is approximately:
/Users/userName/Library/Application/Support/iPhone/Simulator/5.0/Applications/
Then I have that folder sorted by 'last modified'. Once I find the app folder for the app I am working on, I expand it to display the app (and see the app name) and also set a color on the folder. The Finder sometimes doesn't keep the folder sorted by 'last modified' unless the window is closed and reopened.
Upvotes: 4