iOS17问题
背景
之前一直用阿里开源的tidevice对iOS设备做一些操作,但前不久升级iOS17后不行了,tidevice目前也未对iOS17进行支持,报如下错误:
$ tidevice screenshot ios.png
Screenshot saved to ios.png
[I 231113 18:06:36 _device:604] ProductVersion: 17.0
[I 231113 18:06:36 _imagemounter:24] Download https://tool.appetizer.io/JinjunHan/iOSDeviceSupport/raw/master/DeviceSupport/17.0.zip -> /Users/xmly/.tidevice/device-support/17.0.zip
[I 231113 18:06:36 _imagemounter:24] Download https://github.com/JinjunHan/iOSDeviceSupport/raw/master/DeviceSupport/17.0.zip -> /Users/xmly/.tidevice/device-support/17.0.zip
Traceback (most recent call last):
File "/Users/xmly/.pyenv/versions/3.8.9/lib/python3.8/site-packages/tidevice/_device.py", line 484, in start_service
return self._unsafe_start_service(name)
File "/Users/xmly/.pyenv/versions/3.8.9/lib/python3.8/site-packages/tidevice/_device.py", line 505, in _unsafe_start_service
raise MuxServiceError(error)
tidevice.exceptions.MuxServiceError: InvalidService
其实根本原因是苹果官方从iOS 17起使用了新的通讯方式与设备通讯,可进一步参考Missing iOS 17 device support files、pymobiledevice3 RemoteXPC,这意味着官方不再提供DeveloperDiskImage.dmg
,国内收集的iOSDeviceSupport也就仅支持到iOS 16.7
相关issue
- DeveloperDiskImage.dmg for iOS 17 not found in Xcode 15
- idevicescreenshot broken with Xcode 15 + iOS 17
- idevicedebug + ideviceimagemounter broken with iOS 17
- idb iOS17 Support
- iOS 17 support
...等等,这里就不一一列举
通过寻找,发现pymobiledevice3项目也许可行
安装
python3 -m pip install -U pymobiledevice3
低于iOS13 需要安装依赖openssl
brew install openssl
iOS 17截图解决方案
在iOS 17上亲测可用,只是感觉截图有点慢
sudo python3 -m pymobiledevice3 remote start-quic-tunnel
pymobiledevice3 developer dvt screenshot /path/to/screen.png
- 命令太长了,在
~/.zshrc
alias个短命令
# iOS17截图解决方案,增加快捷方式
alias start-quic-tunnel="sudo python3 -m pymobiledevice3 remote start-quic-tunnel"
alias screenshot="pymobiledevice3 developer dvt screenshot"
- 再次尝试
$ start-quic-tunnel
Password:
2023-11-13 17:32:28 MacBook-Pro.local pymobiledevice3.cli.remote[50492] INFO tunnel created
UDID: 00008110-001E51CE0E9A801E
ProductType: iPhone14,5
ProductVersion: 17.0
Interface: utun2
RSD Address: fd0b:c082:9c11::1
RSD Port: 54161
Use the follow connection option:
--rsd fd0b:c082:9c11::1 54161
获取到输出的--rsd fd0b:c082:9c11::1 54161
$ screenshot xx.png --rsd fd0b:c082:9c11::1 54161
$ open .
pymobiledevice3
支持iOS>=17.0
NOTE: Currently, this is only supported on macOS
Starting at iOS 17.0, Apple introduced the new CoreDevice framework to work with iOS devices. This framework relies on the RemoteXPC protocol. In order to communicate with the developer services you'll be required to first create trusted tunnel as follows:
sudo python3 -m pymobiledevice3 remote start-quic-tunnel
(almost) all of pymobiledevice3 accept an additional
--rsd
option for connecting to the service over this new tunnel
其他功能
pymobiledevice3 还有其他很多功能,可参照如下help
Usage: python -m pymobiledevice3 [OPTIONS] COMMAND [ARGS]...
Options:
-h, --help Show this message and exit.
Commands:
activation activation options
afc FileSystem utils
amfi amfi options
apps application options
backup2 backup utils
bonjour bonjour options
companion companion options
crash crash report options
developer developer options.
diagnostics diagnostics options
lockdown lockdown options
mounter mounter options
notification notification options
pcap sniff device traffic
power-assertion Create a power assertion (wraps...
processes processes cli
profile profile options
provision privision options
remote remote options
restore restore options
springboard springboard options
syslog syslog options
usbmux usbmuxd options
webinspector webinspector options