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

标签 ios shell ios8 filesystems archive

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

# 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

希望这对其他人有帮助!

关于ios - 如何从终端访问 iOS 8 设备上的应用程序数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28618748/

相关文章:

ios - 是否适合用于后台获取?

ios - 核心数据 : disable undo for specific attributes. 推荐的方法不起作用

linux - 杀和杀-9有什么区别?

ios - 在 iOS 8 中的扩展中进行 inapp 购买

ios - 何时不使用核心数据关系

ios - 如何使用动画创建新节并将行移动到该节

linux - 打开和编辑文件对另一个文件也有效

linux - 如何在 bash 中获取键值对文件以转义空格?

ios - 快速加载 View 后自定义自定义键盘高度

ios - 我将如何为 SKPaymentQueue 使用未弃用的 API?