这是一个 go 实现的 ios 自动化测试工具,用于实现在 linux window mac 上实现 ios 自动化
https://github.com/danielpaulus/go-ios
!! ios17 已经无法挂载开发者镜像
# 功能简介
- 安装 ipa 到 iphone
- 在多平台运行 XCTest,包括 webdriverAgent
- 启动和停止应用
- 无需手动点击弹窗就可以配对设备
- 自动安装开发者镜像
- 在设备上执行热状态和网络仿真(弱网测试)
# 安装
两种方案
- npm install go-ios
- 下载代码,编译 go 项目
所有命令的默认输出都是 JSON 格式。如果你更喜欢人类可读的输出结果,请在命令中指定 --nojson 选项。
默认情况下,除非指定 --udid=some_udid 开关,否则命令将使用找到的第一个设备。
指定 -v 用于调试日志,指定 -t 用于转储每条信息。
# 使用
!!windows 要安装并启动 itunes;
!!ios17 目前很多功能不支持,手上也没有其他设备,所以很多功能试不了
!!若命令未指定–udid,则命令默认在列表中第一个设备执行
# 查看设备列表
以下命令类似,windows 如果是自己变异的就用 exe 执行
# mac | |
ios list | |
# windows | |
.\go-ios.exe list |
# 安装开发者镜像
ios image auto
这里有点问题 我的 iphone 设备使用 mac 或者 widnows 都无法成功安装镜像
- 从 github 下载镜像出错,众所周知的原因
- 手动下载后报错,原因暂时位置,并且我的设备时 17.1 了,为什么要下载 16.6 呢?
{"err":"open devimages\\16.6\\DeveloperDiskImage.dmg.signature: The system cannot find the file specified.","image":"devimages\\16.6\\DeveloperDiskImage.dmg","level":"error","msg":"error mounting image","time":"2023-12-06T08:53:56+08:00","udid":"00008101-001E38100242001E"}
经过排查,iphone 需要开启开发者模式:
设置 -》通用 -》隐私与安全性 -》开发者模式
打开之后重启设备
# 设备信息
ios info
# 系统日志
ios syslog
# 应用相关
# 应用列表
ios apps --list 安装应用 不是json输出
ios apps --all 全部应用
ios apps --system 系统应用
# 安装 ipa
# 启动停止应用程序
需要开发者镜像
# 状态模拟
需要开发者镜像
# 崩溃日志
.\go-ios.exe crash ls 查看崩溃日志
.\go-ios.exe crash cp "*" "./" 拷贝日志到指定目录
# 截图
ios17 不行
# 抓包
需要进程 id,进程 id 需要开发者镜像
# 重启
# 磁盘相关
查看磁盘大小
(base) PS D:\git\go-ios> .\go-ios.exe diskspace
{"level":"info","msg":"no udid specified using first device in list","time":"2023-12-12T08:28:29+08:00","udid":"00008101-001E38100242001E"}
Model: iPhone13,2
BlockSize: 512
FreeSpace: 34.5GB
UsedSpace: 93.3GB
TotalSpace: 127.9GB
# 配对密钥
.\go-ios.exe readpair