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:40

I faced the same issue when I stored the full path using CoreData. When retrieving the full path, it return null because the document folder UUID is different every time the app restarts. Following is my resolution:

  1. Make sure storing only the relative path of the document / file in CoreData. E.g. store "Files/image.jpg" instead of "/Users/yourname/.../Applications/UUID/Document/Files/image.jpg".
  2. Use the following to retrieve the app document location:

    [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

  3. Concatenate both #2 and #1 to get the full path of the document / file you want to retrieve.
You can refer to Apple Developer Note: https://developer.apple.com/library/ios/technotes/tn2406/_index.html

查看更多
走好不送
3楼-- · 2020-01-25 04:41

Despite the fact that here are many answers, none of them provides an understanding of how the folder structure of the iOS 8.3 simulators have changed and are not providing a quick way to find the App's Data (Documents folder).

Since iOS 8 the Data storage folder(s) of an App are separate from the App's executable files while the iOS 7 and below are having the same folder structure, the only difference being the fact that all the simulators (different types and versions) are now in one, big folder.

So, the path to an iOS 8,7,6 simulator is the following:

~/Library/Developer/CoreSimulator/Devices

Every simulator is now contained in a folder named with an unique identifier which changes at every reset of a simulator.

You can find the Identifier for each of your devices & simulators by going to Xcode > Window > Devices (the first 3 or 4 characters of the identifier are more than enough to remember).

To find the one on which you have installed your app(s) on, take a look at your Run scheme > devices (screen 2).

screen 1

screen 2

Now, after you identify your simulator, depending on its version the folder structure is very different:

On iOS 8 the executable and the data folder of an app are in different folders:

Executable: ~/Library/Developer/CoreSimulator/Devices/[simID]/data/Containers/Bundle/Application/[appID]

Data Folder: ~/Library/Developer/CoreSimulator/Devices/[simID]/data/Containers/Data/Application/[appID]/

Documents Folder: ~/Library/Developer/CoreSimulator/Devices/[simID]/data/Containers/Data/Application/[appID]/Documents

On iOS 7 and below the folder structure is the same as before only remember that now every simulator is in the same folder (see above).

查看更多
Melony?
4楼-- · 2020-01-25 04:43

The best way to find the path is to do via code.

Using Swift, just paste the code below inside the function application in your AppDelegate.swift

let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let documentsPath = paths.first as String
println(documentsPath)

For Obj-C code, look answer from @Ankur

查看更多
▲ chillily
5楼-- · 2020-01-25 04:44

Where is the Documents Directory for the iOS 8 Simulator

You may have noticed that the iPhone Simulator has changed with Xcode 6, and with it – of course – the path to your simulated apps’ Documents Directory. At times we may need to take a look at it.

Finding that path is not as easy as it was once, namely Library/Application Support/iPhone Simulator/7.1/Applications/ followed by a cryptic number representing your app.

As of Xcode 6 and iOS 8 you’ll find it here: Library/Developer/CoreSimulator/Devices/cryptic number/data/Containers/Data/Application/cryptic number

http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/

查看更多
孤傲高冷的网名
6楼-- · 2020-01-25 04:47

With the adoption of CoreSimulator in Xcode 6.0, the data directories are per-device rather than per-version. The data directory is ~/Library/Developer/CoreSimulator/Devices//data where can be determined from 'xcrun simctl list'

Note that you can safely delete ~/Library/Application Support/iPhone Simulator and ~/Library/Logs/iOS Simulator if you don't plan on needing to roll back to Xcode 5.x or earlier.

查看更多
相关推荐>>
7楼-- · 2020-01-25 04:47

For Swift 3.x

if let documentsPath = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask).first?.path {
        print("Documents Directory: " + documentsPath)
    }
查看更多
登录 后发表回答