Is there any way to see the file system on the iOS simulator?

后端 未结 12 1637
清歌不尽
清歌不尽 2020-11-30 17:15

Is there any way to browse the file system of a currently running or just killed iOS simulator? I\'d settle for being able to see a specific app\'s files if there\'s a way t

相关标签:
12条回答
  • 2020-11-30 17:34

    first, get simulator list with device ID from terminal

    1. instruments -s devices
    2. xcrun simctl list

    Then go put device id below path. you will be get specific simulator file system ~/Library/Developer/CoreSimulator/Devices/{{deviceID}}

    0 讨论(0)
  • 2020-11-30 17:35

    Open the program "Activity Monitor", search for your App (just the apps name, not the simulator), click "Informations" and open "Open files and ports". Copy the second entry (something like /Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/YourApp). This is the running app, while <...>/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/ is the bundle, and <...>/B97A9504-0FA5-4826-BB6D-A2335A676459/* the sand-boxed folder.

    If you pass this as open "/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/" to the terminal, the folder will open in Finder.

    Sounds complicated but isn't.

    0 讨论(0)
  • 2020-11-30 17:39

    Easy. Fast. Xcode 10+.

    1. Use print(NSHomeDirectory()) and copy the path.
    2. Open Finder app and press Shift+Cmd+G
    3. Paste the copied path and press GO

    Alternative for 1. is to catch a breakpoint and do po NSHomeDirectory() in console.

    0 讨论(0)
  • 2020-11-30 17:41

    There is a nifty app that also supports the XCode 6 simulator.

    https://github.com/somegeekintn/SimDirs

    It is awesome, use it!

    0 讨论(0)
  • 2020-11-30 17:46

    If you want to automate getting the location or use that folder in scripting, you can get the precise location from a running simulator with the following command:

    xcrun simctl get_app_container booted my.app.id data
    
    0 讨论(0)
  • 2020-11-30 17:49

    based on zsero answer

    Details

    macOS 10.13.1

    Solution 1

    Run the following line in the terminal

    Template

    open `xcrun simctl get_app_container booted BUNDLEID_OF_YOUR_APP data` -a Finder
    

    Full Sample

    open `xcrun simctl get_app_container booted com.Test data` -a 
    

    BUNDLEID_OF_YOUR_APP ???

    BUNDLEID_OF_YOUR_APP = "Bundle Identifier"

    Features of the solution 1

    • open file to get app simulator directory

    Solution 2

    Create a bash scrip with a name of your app and code:

    script_file_name = `basename "$0"`
    open `xcrun simctl get_app_container booted $script_file_name data`
    

    Features of the solution 2

    • open file to get app simulator directory
    • rename file to get another app simulator directory

    Result

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