主要工具: WebDriverAgent + facebook-wda

安装 WebDriverAgent 并真机运行

1,git clone https://github.com/facebook/WebDriverAgent
2,./Scripts/bootstrap.sh
3,还要修改WebDriverAgent的BundleID,在WebDriverAgentRunner Build Settings 中 Product Bundle Identifier修改

4,然后commond + U 运行WebDriverAgentRunner
5,看到手机上安装了WebDriverAgent,代表安装成功
6,安装端口转发工具 brew install libimobiledevice,然后 iproxy 8100 8100
7,转发成功后访问 http://localhost:8100/status 将会有 JSON 内容显示

安装facebook-wda

终端操作:pip install –pre facebook-wda
github:https://github.com/openatx/facebook-wda

libimobiledevice详解

有人逆向出iOS设备与Windows/Mac Host接口的通讯协议,最终开发了横跨三大桌面平台的非官方版本USB接口library,它同iTools一样,都是可以替代iTunes,进行iOS设备管理的工具。
安装方法:
brew update
brew install libimobiledevice
//libimobiledevice中并不包含ipa的安装命令,所以还需要安装
brew install ideviceinstaller

使用命令:

命令 功能
deviceinstaller -i xxx.ipa 安装一个ipa文件到手机上
ideviceinstaller -U [bundleID] 卸载应用
idevicesyslog 查看系统日志
idevice_id –list 查看当前已连接的设备的UUID
idevicescreenshot 截图
ideviceinfo 查看设备信息
idevicedate 获取设备时间
iproxy 设置代理(端口转发的工具)
ideviceimagemounter 挂载DeveloperDiskImage,用于调试
idevicename 获取设备名称
idevicedebug 调试程序(需要预先挂载DeveloperImage)
ideviceprovision list 查看和操作设备的描述文件

问题:
ideviceinstaller安装ipa报错 “Could not connect to lockdownd. Exiting.”
出现这个问题一般是因为新版iOS操作系统的通信协议可能有些微调,参考下面的stackoverflow的帖子,可以通过下面的命令尝试更新使用最新的libimobiledevice构建版本(当然,前提是这个开源项目会一直有人去维护~)。
http://stackoverflow.com/questions/39035415/ideviceinstaller-fails-with-could-not-connect-to-lockdownd-exiting

The best solution here is to get the latest libimobiledevice, which has a fix for this particular issue:

brew uninstall ideviceinstaller
brew uninstall libimobiledevice
brew install –HEAD libimobiledevice
brew link –overwrite libimobiledevice
brew install ideviceinstaller
brew link –overwrite ideviceinstaller

应用示例

使用 python 来玩微信跳一跳 https://github.com/wangshub/wechat_jump_game

建议文章:

  1. 《iOS开发的另类神器:libimobiledevice开源包》
  2. 《教你用 Python 来玩微信跳一跳》
  3. 《使用 Python 库 facebook-wda 完成网易云音乐 iOS 客户端的自动化测试 (示例)》
  4. 《ATX 文档 - iOS 真机如何安装 WebDriverAgent》
  5. 《iOS 真机调试如何安装 WebDriverAgent》