项目地址:https://github.com/doronz88/pymobiledevice3
首先先介绍一下pymobiledevice3,
pymobiledevice3是用Python3 实现的,用于处理 iDevices(iPhone 等)。它可以跨平台使用,支持:windows、Linux、macOS。
【安装】
git clone git@github.com:doronz88/pymobiledevice3.git
cd pymobiledevice3
python3 -m pip install -U -e .
【常用命令】
pymobiledevice3提供的命令如下:

1、查看iOS设备的udid:pymobiledevice3 usbmux list

这个命令类似于idb的 idb list-targets和libimobiledevice的 idevice_id -l:


2、查看app的bundle id,通过输入命令:
pymobiledevice3 apps list --udid f89d929e8c45a81c0fe2d2xxxxxxxxxxxxxxxxxxxf
可以查看手机安装app的info.plist中的部分信息,如:

这个命令类似于idb的 list-apps,
idb list-apps --udid f89d929e8c45a81c0fe2d2xxxxxxxxxxxxxxxxf

类似于libimobiledevice的ideviceinstaller -u f89d929e8c45a81c0fe2d2xxxxxxxxxxxxxxxf -l

3、安装应用:
pymobiledevice3 apps install /Users/testmanzhang/Downloads/axxx_app_ios_internal_global_debug_3.x.x.xxxx.ipa

这个命令类似于idb的install,
idb install /Users/testmanzhang/Downloads/axxx_app_ios_internal_global_debug_x.x.x.xxxx.ipa

类似于libimobiledevice的ideviceinstaller,
ideviceinstaller -i /Users/testmanzhang/Downloads/axxx_app_ios_internal_global_debug_x.x.x.xxxx.ipa

4、卸载应用:
pymobiledevice3 apps uninstall com.xxxxxxx.ios

类似于idb的uninstall,idb uninstall com.xxxxxx.ios

类似于libimobiledevice的ideviceinstaller,
ideviceinstaller -U com.xxxxxxx.ios

5、查看系统日志:
pymobiledevice3 syslog collect /Users/testmanzhang/Downloads/11111.logarchive
生成的日志文件到达948M后收集停止,在mac上使用console.app打开查看
这个命令类似于idb log、libimobiledevice的idevicesyslog
6、重启设备命令:pymobiledevice3 diagnostics restart
7、截图命令:pymobiledevice3 developer screenshot /Users/testmanzhang/Downloads/2222.png
8、访问应用的沙盒目录:pymobiledevice3 apps afc com.xxxxxxx.ios,
启动的是xonsh-afc shell,它是在xonsh的基础上增加了afc,即Apple File Conduit。
进入shell后界面如下:

它提供的命令有:

例如,ls,显示的就是iOS对应应用ios.glazero.ios的沙盒目录:

例如,cd进入Documents/Logs目录,可以将目录下的文件拉取到本地:

pull xxxxxx_app_ios_20241014.log /Users/testmanzhang/Downloads
也可以使用cat和grep查看该日志文件
cat xxxxxx_app_ios_20241014.log | grep "addDpUpdateDelegate"
