我们正在我们的 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/