Chr*_*ams 163 iphone nsfilemanager ios
有没有办法浏览当前正在运行或刚刚杀死的iOS模拟器的文件系统?如果有办法,我会满足于能够看到特定应用程序的文件.
请注意,我不想以编程方式执行此操作.我想在Finder中查看/打开文件.
Ken*_*ner 219
更新:从iOS 8开始:
〜/资源库/开发/ CoreSimulator /设备
过去的位置是:
〜/ Library/Application Support/iPhone Simulator
它有你运行的所有模拟器模型(4.0,4.1,5.0等)的目录,转到你在Xcode中运行的模拟器.
进入文件夹后,转到"应用程序",选择显示文件日期的"查找程序"选项,然后按日期排序.您的应用程序将是最新的,因为它只是更改了目录...
目录中包含与您的应用程序相关的所有内容.您甚至可以在运行之间删除文件,以恢复到已知状态的存储数据库,例如......
我经常去那里我将iPhone模拟器目录保存在我的Finder侧栏中.
请注意,对于iOS8,模拟器文件夹位于完全不同的目录中 - 实际上分成几个目录,每次运行应用程序时,应用程序特定文件的文件夹名称都会更改.
Moh*_*sen 76
~/Library/Developer/CoreSimulator/Devices
Run Code Online (Sandbox Code Playgroud)
~/Library/Developer/CoreSimulator/Devices/{{Device Code}}/data/Containers/Bundle/
Run Code Online (Sandbox Code Playgroud)
Vik*_*ica 27
打开程序"活动监视器",搜索您的应用程序(只是应用程序名称,而不是模拟器),单击"信息"并打开"打开文件和端口".复制第二个条目(类似于/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/YourApp).这是正在运行的应用程序,<...>/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/而是捆绑包和<...>/B97A9504-0FA5-4826-BB6D-A2335A676459/*沙盒文件夹.
如果您将此传递open "/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/"给终端,该文件夹将在Finder中打开.
听起来很复杂但不是.
Tun*_*Fam 18
print(NSHomeDirectory())并复制路径。Shift+Cmd+G1.的替代方法是捕获一个断点并po NSHomeDirectory()在控制台中执行。
Vas*_*huk 17
基于zsero回答
macOS 10.13.1
在终端中运行以下行
模板
open `xcrun simctl get_app_container booted BUNDLEID_OF_YOUR_APP data` -a Finder
Run Code Online (Sandbox Code Playgroud)
完整样本
open `xcrun simctl get_app_container booted com.Test data` -a
Run Code Online (Sandbox Code Playgroud)
BUNDLEID_OF_YOUR_APP ="捆绑标识符"
如果要自动获取位置或在脚本中使用该文件夹,则可以使用以下命令从运行的模拟器中获取精确位置:
xcrun simctl get_app_container booted my.app.id data
Run Code Online (Sandbox Code Playgroud)
对于 Swift 4.2 及更高版本,打印一个易于使用的路径:
\n#if targetEnvironment(simulator)\n print("::::: SIMULATOR :::::")\n if let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.path {\n print("App Documents Directory:\\n\\(documentsPath)\\n")\n }\n#endif\nRun Code Online (Sandbox Code Playgroud)\n...在源代码位置,例如:
\nfunc application(\n _ application: UIApplication, \n didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?\n) -> Bool {\n // ...\n return true\n}\nRun Code Online (Sandbox Code Playgroud)\n在终端命令行上使用生成的路径或cd。open或者,将路径粘贴到shift-cmd-G“转到文件夹\xe2\x80\xa6”Finder 提示中。
相关答案包括较旧的语言版本:Document Directory Path of iOS 8 Beta Simulator
\n首先,从终端获取带有设备 ID 的模拟器列表
然后将设备 ID 放在路径下方。您将获得特定的模拟器文件系统
~/Library/Developer/CoreSimulator/Devices/{{deviceID}}
| 归档时间: |
|
| 查看次数: |
74470 次 |
| 最近记录: |