Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tidevice

> 开发工具
Open source

tidevice can be used to communicate with iPhone device

2.6K stars0 likes0 views
WebsiteGitHub

About

tidevice can be used to communicate with iPhone device

项目暂停维护 Stop Maintained

考虑到有很多更好的项目,另外该项目也没有实现对iOS17的支持,开发工作量太大,而我也没这么多的时间,所以本项目就暂停维护了。

推荐项目 Alternatives

  • https://github.com/danielpaulus/go-ios
  • https://github.com/doronz88/pymobiledevice3
  • https://github.com/YueChen-C/py-ios-device

虽然项目停了,不过QQ群还是正常开放,欢迎入群讨论。除了不能发广告和一些政治敏感信息,其他的交流还是很开放的。

QQ交流群: 134535547 (进群答案: 自己猜吧,不行就问gpt)

tidevice

iOS17的支持通知

本来想自己实现iOS17的支持,但是发现自己没这个实力,不过社区还是很强大的,目前发现了一个好项目能支持iOS17: pymobiledevice3,这个项目的代码写的非常好,因为太过优秀,我就不继续在tidevice里面去实现了。不过这个项目的命令行好像不太友好,所以我又搞了一个新项目

https://github.com/codeskyblue/tidevice3

基于pymobiledevice3做封装,封装了一些常用的功能,如app install uninstall screenshot。欢迎体验

English

QQ交流群: 134535547 (进群答案: 自己猜吧,不行就问gpt)

该工具能够用于与iOS设备进行通信, 提供以下功能

  • 截图
  • 获取手机信息
  • ipa包的安装和卸载
  • 根据bundleID 启动和停止应用
  • 列出安装应用信息
  • 模拟Xcode运行XCTest,常用的如启动WebDriverAgent测试(此方法不依赖xcodebuild)
  • 获取指定应用性能(CPU,MEM,FPS)
  • 获取指定应用功耗(CPU,GPU,network,display,location)
  • 文件操作
  • Crash日志操作
  • 其他

支持运行在Mac,Linux,Windows上

赞助商

霍格沃兹测试开发学社:中国软件测试开发高端教育品牌,产品由国内顶尖软件测试开发技术专家携手打造。为企业与个人提供专业的技能培训与咨询、测试工具与测试平台、测试外包与测试众包服务。领域涵盖App/Web自动化测试、接口自动化测试、性能测试、安全测试、持续交付/DevOps、测试左移、测试右移、精准测试、测试平台开发、测试管理等方向,联系我们

安装

Python 3.6+

pip3 install -U "tidevice[openssl]"   # Recommend

如果上面的命令提示安装失败,就试试下面的命令。(不过这种方法安装,配对功能就没有了,因为没有办法进行签名)

pip3 install -U tidevice

Windows电脑需要安装并启动Itunes

使用

使用--trace选项可以查看socket数据流

手机配置

iOS 16的手机需要手工开启开发者选项。 开启方法:设置->隐私与安全性->开发者模式 (打开),然后会提示重启 (点击 重新启动) -> 启动后会弹窗 是否打开“开发者模式”?(点击打开)

查看版本号

$ tidevice version
0.1.0

配对

$ tidevice pair
# 配对设备

$ tidevice unpair
# 取消配对设备

列出连接设备

$ tidevice list
List of apple devices attached
00008030-001A35E40212345678 codeskyblue的iPhoneSE

$ tidevice list --json
[
    {
        "udid": "00008030-001A35E40212345678",
        "name": "codeskyblue的iPhoneSE"
    }
]

应用管理

# 安装应用
$ tidevice install example.ipa

# 指定设备安装
$ tidevice --udid $UDID install https://example.org/example.ipa

# 卸载应用
$ tidevice uninstall com.example.demo

# 启动应用
$ tidevice launch com.example.demo

# 停止应用
$ tidevice kill com.example.demo

# 查看已安装应用
$ tidevice applist

# 查看运行中的应用
$ tidevice ps
$ tidevice ps --json output as json

Run XCTest

请先确保手机上已经安装有WebDriverAgent应用

…

Relay

# 转发请求到手机,类似于iproxy
$ tidevice relay 8100 8100

# 转发并把传输的内容用hexdump的方法print出来
$ tidevice relay -x 8100 8100

运行WebDriverAgent

目前已知的几个问题

  • 不支持运行企业证书签名的WDA
  • 数据线可能导致wda连接中断。作者用的数据线(推荐): https://item.jd.com/44473991638.html

wdaproxy这个命令会同时调用xctest和relay,另外当wda退出时,会自动重新启动xctest

# 运行 XCTest 并在PC上监听8200端口转发到手机8100服务
$ tidevice wdaproxy -B com.facebook.wda.WebDriverAgent.Runner --port 8200
...logs...

启动后你就可以使用Appium 或者 facebook-wda 来运行iOS自动化了

facebook-wda example code

import wda
c = wda.Client("http://localhost:8200")
print(c.info)

Appium 需要下面几个配置需要设置一下

"usePrebuiltWDA": "false",
"useXctestrunFile": "false",
"skipLogCapture": "true"

需要在Windows上运行Appium+iOS自动化可以参考下面的帖子 https://testerhome.com/topics/29230 Ref issue #46

运行XCTest UITest

这个不是Unit Tests,而是UITests。具体可以看这里的解释说明 https://fbidb.io/docs/test-execution

以这个项目为例: https://github.com/FeiHuang93/XCTest-Demo 应用分为执行测试的应用 testXCTestUITests 和 被测应用 testXCTest

执行方法

…

挂载开发者镜像

这个步骤其实不太需要,因为如果tidevice的命令需要开发者镜像的时候,会自动去挂载的

# 先在本地路径查找 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
# 如果没有会去网站 https://github.com/iGhibli/iOS-DeviceSupport 下载,下载到路径 ~/.tidevice/device-support/
$ tidevice developer
[I 210127 11:37:52 _device:518] ProductVersion: 12.4
[I 210127 11:37:52 _imagemounter:81] Pushing DeveloperDiskImage.dmg
[I 210127 11:37:52 _imagemounter:94] Push complete
[I 210127 11:37:53 _device:589] DeveloperImage mounted successfully

# 下载所有镜像到本地
$ tidevice developer --download-all

查看设备信息

$ tidevice info

# 查看设备电源信息
$ tidevice info --domain com.apple.mobile.battery --json
{
    "BatteryCurrentCapacity": 53,
    "BatteryIsCharging": true,
    "ExternalChargeCapable": true,
    "ExternalConnected": true,
    "FullyCharged": false,
    "GasGaugeCapability": true,
    "HasBattery": true
}

Known domains are:

…

文件操作


# 查看相册内容
$ tidevice fsync /DCIM/

# 查看T3出行Documents中的内容
$ tidevice fsync -B com.t3go.passenger ls /Documents/

# 下载目录(也支持文件)
$ tidevice pull /Documents ./TmpDocuments/

# 其他操作 rm cat pull push stat tree rmtree mkdir
$ tidevice fsync -h

# 支持查看 /Documents 的App
# com.apple.iMovie iMovie
# com.apple.mobilegarageband 库乐队
# com.apple.clips 可立拍
# com.t3go.passenger T3出行
# com.dji.golite DJI Fly
# com.duokan.reader 多看阅读

Crash日志操作

usage: tidevice crashreport [-h] [--list] [--keep] [--clear] [output_directory]

positional arguments:
  output_directory  The output dir to save crash logs synced from device (default: None)

optional arguments:
  -h, --help        show this help message and exit
  --list            list all crash files (default: False)
  --keep            copy but do not remove crash reports from device (default: False)
  --clear           clear crash files (default: False)

其他常用

# 重启
$ tidevice reboot

# 截图
$ tidevice screenshot screenshot.jpg

# 输出日志 same as idevicesyslog
$ tidevice syslog

性能采集

使用命令行可以直接看到结果,不过最好还是用接口获取

…
…

How to get app performance in python

import time
import tidevice
from tidevice._perf import DataType

t = tidevice.Device()
perf = tidevice.Performance(t, [DataType.CPU, DataType.MEMORY, DataType.NETWORK, DataType.FPS, DataType.PAGE, DataType.SCREENSHOT, DataType.GPU])
#  tidevice version <= 0.4.16:
#  perf = tidevice.Performance(t)

def callback(_type: tidevice.DataType, value: dict):
    print("R:", _type.value, value)

perf.start("com.apple.Preferences", callback=callback)
time.sleep(10)
perf.stop()

DEVELOP

See DEVELOP

Python code style(ZH): https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/#comments

Alternatives

  • https://github.com/danielpaulus/go-ios
  • Go implemented: https://github.com/electricbubble/gidevice
  • https://github.com/SonicCloudOrg/sonic-ios-bridge
  • https://github.com/doronz88/pymobiledevice3 这个库用到的服务很全,还是Python的,参考起来更方便

Thanks

  • C implementation https://github.com/libimobiledevice
  • https://github.com/facebook/idb
  • Python implement of libimobiledevice: https://github.com/iOSForensics/pymobiledevice
  • Apple Device Images: https://github.com/iGhibli/iOS-DeviceSupport
  • https://github.com/anonymous5l/iConsole
  • https://github.com/troybowman/dtxmsg
  • https://github.com/troybowman/ios_instruments_client
  • Binary of libimobiledevice for Windows http://docs.quamotion.mobi/docs/imobiledevice/
  • 使用纯 python 实现 Instruments 协议,跨平台 (win,mac,linux) 获取 iOS 性能数据

LICENSE

MIT

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •https://github.com/danielpaulus/go-ios
  • •https://github.com/doronz88/pymobiledevice3
  • •https://github.com/YueChen-C/py-ios-device
  • •ipa包的安装和卸载
  • •根据bundleID 启动和停止应用
  • •列出安装应用信息
  • •模拟Xcode运行XCTest,常用的如启动WebDriverAgent测试(此方法不依赖xcodebuild)
  • •获取指定应用性能(CPU,MEM,FPS)
  • •获取指定应用功耗(CPU,GPU,network,display,location)
  • •Crash日志操作

> Tags

Pythoniosiphonetideviceusbmuxd

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具