如何从终端访问 iOS 8 设备上的应用程序数据?

How to access application data on an iOS 8 device from terminal?

我们正在 运行 对我们的 iOS 应用程序进行一些测试。该应用程序在 Library/Caches/Logs/ 中生成一个日志文件。在 iOS 7 设备上,我们可以创建包含应用数据的应用程序存档,并将存档从设备复制到我们的本地计算机。使用 libimobiledevice (http://www.libimobiledevice.org/) 中的 ideviceinstaller 实用程序,然后我们可以解压缩存档并提取日志文件:

# Archive the app and copy to our local machine
ideviceinstaller --udid  $DEVICE_ID --archive ${BUNDLE_ID} -o copy=.

# Unzip the archive and redirect the log file to a file in our current directory
unzip -p ${BUNDLE_ID}.ipa "$(unzip -l ${BUNDLE_ID}.ipa | grep -o "Container/Library/Caches/Logs/${LOG_FILE_NAME}")" > ./${LOG_FILE_NAME}

不幸的是,这似乎不再适用于 iOS 8 设备,因为应用程序数据在文件系统中的存储位置发生了变化。特别是,应用程序数据显然不再包含在应用程序存档中:https://developer.apple.com/library/ios/technotes/tn2406/_index.html

我们需要一种方法来访问设备上的此日志文件,并通过 shell 脚本将其复制到我们的本地计算机。我是 iOS 开发的新手,所以我对如何执行此操作或在 iOS 8.

中是否仍然可行感到困惑

如有任何建议,我们将不胜感激,如果有任何需要澄清的地方,请告诉我。

我找到了一个名为 ifuse (https://github.com/libimobiledevice/ifuse) 的实用程序,它可以让我挂载应用程序的沙盒根文件夹并将文件复制到我的本地计算机:

# E.g. ifuse --container com.blah.yourappname <mountpoint>
ifuse --container ${BUNDLE_ID} ~/mnt

# I found I needed to sleep for a few seconds before trying to access
# the filesystem, otherwise I'd get "Device not configured" errors...
sleep 5 

cp ~/mnt/Library/Caches/Logs/${LOG_FILE} ~
umount ~/mnt

希望这对其他人有帮助!