IOS WDA作为独立APP运行方法
一、在VMWare中创建MacOS
- 当前的IOS版本需要MacOS 版本为15及以上
二、在MacOS中安装Xcode
- 跟着AppStore上的走
三、Xcode中添加开发者账户
如图所示:

四、将WebDriverAgent下载到MacOS中
- 使用命令
git clone https://github.com/appium/WebDriverAgent.git
五、双击打开WebDriverAgent.xcodeproj文件
-
进入到刚下载下来的WebDriverAgent目录中,双击打开WebDriverAgent.xcodeproj文件
- image.png
六、在打开的WebDriverAgent.xcodeproj文件中进行设置
-
设置WebDriverAgentLib:
-
修改Signing & Capabilities中的相关内容
- image.png
-
检查Build Settings中是否也同步修改了
- image.png
-
-
设置WebDriverAgentRunner
-
修改Signing & Capabilities中的相关内容
- image.png
-
检查Build Settings中是否也同步修改了
- image.png
-
七、生成WDA.ipa文件
-
在终端中输入
xcodebuild build-for-testing -scheme WebDriverAgentRunner -sdk iphoneos -configuration Release -derivedDataPath /tmp/derivedDataPath ARCHS=arm64-
输入命令图片:
- image.png
-
运行成功的截图:
- image.png
-
编译执行成功后,进入Release-iphoneos并创建一个Payload的文件夹
$ cd /tmp/derivedDataPath
$ cd Build/Products/Release-iphoneos # path might be different
# Created folder `Payload` and put `.app` into it
# then compressed to zip, change extention name to `.ipa`. That's all.
$ mkdir Payload && cp -r *.app Payload
-
将/Payload/WebDriverAgentRunner-Runner.app/Frameworks中所有XC开头的文件(夹)删除
- image.png
-
使用zip命令将Payload文件夹打包成一个ipa文件
zip -r WDA.ipa Payload
八、使用iOS App Signer将WDA.ipa重签名
iOS App Signer下载路径:iOS App Signer - Instructions (dantheman827.github.io)
-
将iOS App Signer直接拖到MacOS中
- image.png
-
重签名WDA.ipa文件(为了方便可将WDA.ipa文件移至桌面目录)
-
设置WDA.ipa路径和认证用户,其他默认。然后点击Start按钮:
- image.png
-
* 弹窗中设置生成文件的名称
* 
九、将生成的WDA2.ipa文件安装到目标IPhone手机上
使用爱思助手直接安装
使用tidevice3进行安装
# 安装tidevice3
pip install tidevice3
# 使用tidevice3将WDA2.ipa安装至iPhone手机上
python -m tidevice3 install WDA2.ipa
十、查看安装结果
-
点击手机主页中出现的WebDriverAgentRunner的App
image.png 会有黑色的弹窗出现,随后又推到了系统后台,并且页面中出现了隐隐的Automation Running的内容
-
进入浏览器输入
localhost:8100/status,如果出现了json格式的内容,则说明启动成功。image.png
自动化环境的搭建
一、windows上将wintun.dll添加到C:\Windows\System32中
intun.dll官方链接:Wintun – Layer 3 TUN Driver for Windows
- image.png
- image.png
- image.png
二、下载go-ios
github链接:https://github.com/danielpaulus/go-ios
将下载的压缩包解压后,添加到环境变来那个里面
三、使用go-ios启动wda
使用命令
ios tunnel start --userspace启动通信隧道每次运行前,使用命令
ios --udid=00008101-000849813698001E image auto重载一下镜像使用命令
ios runwda --udid=00008101-000849813698001E --bundleid=com.th.WebDriverAgentRunner.xctrunner --testrunnerbundleid=com.th.WebDriverAgentRunner.xctrunner --xctestconfig=WebDriverAgentRunner.xctest启动wda使用命令
ios forward 8100 8100将IPhone手机上的8100端口映射到电脑8100端口上
四、(验证)验证wda启动状态
创建session
-
请求:
-
方式:POST
链接:127.0.0.1:8100/session
请求体:
{ "capabilities": { "firstMatch": [ { "bundleId": "com.th.WebDriverAgentRunner.xctrunner", "arguments": [], "environment": {}, "eventloopIdleDelaySec": 0, "shouldWaitForQuiescence": true, "shouldUseTestManagerForVisibilityDetection": false, "maxTypingFrequency": 60, "shouldUseSingletonTestManager": true, "shouldTerminateApp": false, "forceAppLaunch": false, "useNativeCachingStrategy": true, "forceSimulatorSoftwareKeyboardPresence": true } ], "alwaysMatch": {} } }
-
-
响应内容(例)
{ "value": { "sessionId": "94356B7F-4DAC-4E01-8C02-14F4A2DCEEFA", "capabilities": { "sdkVersion": "18.3.2", "device": "iphone" } }, "sessionId": "94356B7F-4DAC-4E01-8C02-14F4A2DCEEFA" }
获取状态
-
请求:
方式:GET
链接:127.0.0.1:8100/status
-
响应内容(例)
{ "value": { "build": { "version": "9.2.0", "time": "Mar 25 2025 18:45:32", "productBundleIdentifier": "com.facebook.WebDriverAgentRunner" }, "os": { "testmanagerdVersion": 65535, "name": "iOS", "sdkVersion": "18.4", "version": "18.3.2" }, "device": "iphone", "ios": { "ip": "192.168.0.101" }, "message": "WebDriverAgent is ready to accept commands", "state": "success", "ready": true }, "sessionId": "94356B7F-4DAC-4E01-8C02-14F4A2DCEEFA" }
问题处理
一.如何配置指定的Xcode command-line tools
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer














