Document Directory Path of iOS 8 Beta Simulator

2020-01-25 03:54发布

In iOS 7, the document directory of the iOS simulators can be found in:

/Users/Sabo/Library/Application Support/iPhone Simulator/

However, in iOS 8 Beta Simulator, I can't find the corresponding directory for iOS 8 in the directory above.

Where's the document directory path for the iOS 8 Simulator?

enter image description here

21条回答
霸刀☆藐视天下
2楼-- · 2020-01-25 04:30

I recommend a nice utility app called SimPholders that makes it easy to find the files and folders while developing your iOS app. It has a new version to work with the new simulators called SimPholders2. It can be found at simpholders.com

查看更多
Explosion°爆炸
3楼-- · 2020-01-25 04:34

If your app uses CoreData, a nifty trick is to search for the name of the sqlite file using terminal.

find ~ -name my_app_db_name.sqlite

The results will list the full file paths to any simulators that have run your app.

I really wish Apple would just add a button to the iOS Simulator file menu like "Reveal Documents folder in Finder".

查看更多
一夜七次
4楼-- · 2020-01-25 04:34

in Appdelegate, put this code to see Document and Cache Dir:

#if TARGET_IPHONE_SIMULATOR
    NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
    NSArray* cachePathArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString* cachePath = [cachePathArray lastObject];
    NSLog(@"Cache Directory: %@", cachePath);
#endif

on Log:

Documents Directory: /Users/xxx/Library/Developer/CoreSimulator/Devices/F90BBF76-C3F8-4040-9C1E-448FAE38FA5E/data/Containers/Data/Application/3F3F6E12-EDD4-4C46-BFC3-58EB64D4BCCB/Documents/

Cache Directory: /Users/xxx/Library/Developer/CoreSimulator/Devices/F90BBF76-C3F8-4040-9C1E-448FAE38FA5E/data/Containers/Data/Application/3F3F6E12-EDD4-4C46-BFC3-58EB64D4BCCB/Library/Caches

查看更多
闹够了就滚
5楼-- · 2020-01-25 04:36

on my computer, the path is:

~/Library/Developer/CoreSimulator/Devices/1A8DF360-B0A6-4815-95F3-68A6AB0BCC78/data/Container/Data/Application/

NOTE: probably those long IDs (i.e UDIDs) are different on your computer.

查看更多
The star\"
6楼-- · 2020-01-25 04:38

It is correct that we need to look into the path ~/Library/Developer/CoreSimulator/Devices/.

But the issue I am seeing is that the path keeps changing every time I run the app. The path contains another set of long IDs after the Application string and that keeps changing every time I run the app. This basically means that my app will not have any cached data when it runs the next time.

查看更多
beautiful°
7楼-- · 2020-01-25 04:38

update: Xcode 7.2 • Swift 2.1.1

if let documentsPath = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first?.path {
    print(documentsPath)   // "var/folder/.../documents\n" copy the full path
}

Go to your Finder press command-shift-g (or Go > Go to Folder... under the menu bar) and paste that full path "var/folder/.../documents" there and press go.

查看更多
登录 后发表回答