Document directory path of Xcode Device Simulator

前端 未结 21 1429
旧巷少年郎
旧巷少年郎 2020-11-28 02:28

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

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

However,

相关标签:
21条回答
  • 2020-11-28 02:47

    If you like to go into the app folders to see what's going on and don't want to have to go through labyrinthine UUDID's, I made this: https://github.com/kallewoof/plget

    and using it, I made this: https://gist.github.com/kallewoof/de4899aabde564f62687

    Basically, when I want to go to some app's folder, I do:

    $ cd ~/iosapps
    $ ./app.sh
    $ ls -l
    total 152
    lrwxr-xr-x  1 me  staff    72 Nov 14 17:15 My App Beta-iOS-7-1_iPad-Retina.iapp -> iOS-7-1_iPad-Retina.dr/Applications/BD660795-9131-4A5A-9A5D-074459F6A4BF
    lrwxr-xr-x  1 me  staff    72 Nov 14 17:15 Other App Beta-iOS-7-1_iPad-Retina.iapp -> iOS-7-1_iPad-Retina.dr/Applications/A74C9F8B-37E0-4D89-80F9-48A15599D404
    lrwxr-xr-x  1 me  staff    72 Nov 14 17:15 My App-iOS-7-1_iPad-Retina.iapp -> iOS-7-1_iPad-Retina.dr/Applications/07BA5718-CF3B-42C7-B501-762E02F9756E
    lrwxr-xr-x  1 me  staff    72 Nov 14 17:15 Other App-iOS-7-1_iPad-Retina.iapp -> iOS-7-1_iPad-Retina.dr/Applications/5A4642A4-B598-429F-ADC9-BB15D5CEE9B0
    -rwxr-xr-x  1 me  staff  3282 Nov 14 17:04 app.sh
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 com.mycompany.app1-iOS-8-0_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/129FE671-F8D2-446D-9B69-DE56F1AC80B9/data/Containers/Data/Application/69F7E3EF-B450-4840-826D-3830E79C247A
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 com.mycompany.app1-iOS-8-1_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/414E8875-8875-4088-B17A-200202219A34/data/Containers/Data/Application/976D1E91-DA9E-4DA0-800D-52D1AE527AC6
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 com.mycompany.app1beta-iOS-8-0_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/129FE671-F8D2-446D-9B69-DE56F1AC80B9/data/Containers/Data/Application/473F8259-EE11-4417-B04E-6FBA7BF2ED05
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 com.mycompany.app1beta-iOS-8-1_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/414E8875-8875-4088-B17A-200202219A34/data/Containers/Data/Application/CB21C38E-B978-4B8F-99D1-EAC7F10BD894
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 com.mycompany.otherapp-iOS-8-1_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/414E8875-8875-4088-B17A-200202219A34/data/Containers/Data/Application/DE3FF8F1-303D-41FA-AD8D-43B22DDADCDE
    lrwxr-xr-x  1 me  staff    51 Nov 14 17:15 iOS-7-1_iPad-Retina.dr -> simulator/4DC11775-F2B5-4447-98EB-FC5C1DB562AD/data
    lrwxr-xr-x  1 me  staff    51 Nov 14 17:15 iOS-8-0_iPad-2.dr -> simulator/6FC02AE7-27B4-4DBF-92F1-CCFEBDCAC5EE/data
    lrwxr-xr-x  1 me  staff    51 Nov 14 17:15 iOS-8-0_iPad-Retina.dr -> simulator/129FE671-F8D2-446D-9B69-DE56F1AC80B9/data
    lrwxr-xr-x  1 me  staff    51 Nov 14 17:15 iOS-8-1_iPad-Retina.dr -> simulator/414E8875-8875-4088-B17A-200202219A34/data
    lrwxr-xr-x  1 me  staff   158 Nov 14 17:15 org.cocoapods.demo.pajdeg-iOS-8-0_iPad-Retina.iapp -> /Users/me/Library/Developer/CoreSimulator/Devices/129FE671-F8D2-446D-9B69-DE56F1AC80B9/data/Containers/Data/Application/C3069623-D55D-462C-82E0-E896C942F7DE
    lrwxr-xr-x  1 me  staff    51 Nov 14 17:15 simulator -> /Users/me/Library/Developer/CoreSimulator/Devices
    

    The ./app.sh part syncs the links. It is necessary basically always nowadays as apps change UUID for every run in Xcode as of 6.0. Also, unfortunately, apps are by bundle id for 8.x and by app name for < 8.

    0 讨论(0)
  • 2020-11-28 02:48

    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.

    0 讨论(0)
  • 2020-11-28 02:49

    The simulators are located under:

    ~/Library/Developer/CoreSimulator/

    Here, they are listed as directories with UUID names. Use sort by 'Date modified' to find the latest one. Inside navigate to:

    /data/Containers/Data/Application/

    Here you will get a list of all the applications on that device. You can again sort this to get the latest app.

    NOTE: Xcode changes the directory name every time you run the app, so don't rely on making alias/short cuts on desktop.

    The easiest way is to use the app here, which does everything automatically.

    0 讨论(0)
  • 2020-11-28 02:49

    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

    0 讨论(0)
  • 2020-11-28 02:49

    For Swift 3.x

    if let documentsPath = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask).first?.path {
            print("Documents Directory: " + documentsPath)
        }
    
    0 讨论(0)
  • 2020-11-28 02:50

    NSLog below code somewhere in "AppDelegate", run your project and follow the path. This will be easy for you to get to the documents rather than searching randomly inside "~/Library/Developer/CoreSimulator/Devices/"

    Objective-C

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

    Swift
    If you are using Swift 1.2, use the code below which will only output in development when using the Simulator because of the #if #endif block:

    #if arch(i386) || arch(x86_64)
      let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! NSString
      NSLog("Document Path: %@", documentsPath)
    #endif
    

    Copy your path from "/Users/ankur/Library/Developer/CoreSimulator/Devices/7BA821..." go to "Finder" and then "Go to Folder" or command + shift + g and paste your path, let the mac take you to your documents directory :)

    0 讨论(0)
提交回复
热议问题