App Dev Guy
App Dev Guy

Reputation: 5546

Swift Simulator folder location

I have found half a dozen answers about where the iPhone Simulator folder is. This does not display my iPad Applications though.

Does anyone know where the iPad Simulator folder location is or a way to get the location?

Upvotes: 1

Views: 4020

Answers (3)

App Dev Guy
App Dev Guy

Reputation: 5546

Direct to the directory containing all simulators:

  1. Right Click on the "Finder" icon in your dock

  2. Click on Go to Folder

    ~/Library/Developer/CoreSimulator/Devices/

Swift

Use this print statement:

print(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last)

Objective-C

You can find the exact location by using NSLog Print statement

NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

Then follow the first set of instructions with your location.

Upvotes: 5

Chirag
Chirag

Reputation: 259

The folder location has been changed, instead of going to iPhone Simulator you have to go to Core Simulator.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", cachesDirectory, fileName];
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
    return filePath;
}
else {
    return filePath;
}

This code will show how you can check the files stored in the cache and how you can find the folder location.

Print description for the cache directory to get the path.

Upvotes: 0

ashForIos
ashForIos

Reputation: 399

Put this code in your viewDidLoad

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(@"path-%@",documentsDirectory);

Then open finder in your mac. Press Command+Shift+G and input the "documentsDirectory" that was printed in console using NSLog. That will show your path for the app document directory.

Upvotes: 0

Related Questions