安装webDriverAgent和跑测试脚本遇到的坑
1、首先,背景是需要在 iOS 11.3 的手机上跑,xcode版本较低出现


需要安装最新版本的xcode,那么就涉及到电脑系统也要是相应匹配的。建议到appStore下载,以后更新的时候可以直接在appStore更新。自己直接拿包去安装的话,appStore检测不到更新,更新起来还要找相匹配的版本,比较麻烦。
写这篇文章的时候用的 【macOS 10.13.5】【 xcode 9.4】亲测没什么问题
2、编译 webDriverAgent ,根据文章 https://www.jianshu.com/p/efa9ac4900a6 11.2和11.3正常的话编译不会出问题。我这边出的问题是没配置好相应目录下的内容报错,搜了很多没找到,也走了一些弯路,贴出来网上大家可以搜到了作为一个参考吧。
注意下面不同的目录和不同的tab
编译WebDriverAgentLib

编译WebDriverAgentRunner

当时我在WDARunner的General Tab 下已经修改过 bundle identifier ,没在Build Settings Tab 下改 product bundle identifier 所以会出错

搜这个报错信息搜到了这个可以作为参考
Make sure you are signed in with developer account in Xcode.
Navidate to the folder /node_modules/appium-xcuitest-driver/WebDriverAgent/
Open the WebDriverAgent.xcodeproj project in Xcode.
Change the bunlder identifier for WebDriverAgentLib, WebDriverAgentRunner from com.facebook.Webdriver** to your choice so you can sign it with your provisioning profile.
Build the project for WebDriverAgentLib, WebDriverAgentRunner and IntegrationApp targets.
然后通过终端建立服务WebDriverAgent:进入WebDriverAgent 文件夹,建立服务。
$ cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
$ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=真机的udid' test
3、第一次用在手机上运行起来了(可能不应该直接运行到手机吧),这些报错估计运行其他工程也会出现,在手机上跑的时候提示不能锁屏,但手机其实没有锁屏。

这种时候可以拔掉数据线,重启xcode,数据线连上手机,解锁手机后再跑一遍WDA。如果还是不行,就重启手机,重启xcode解锁手机后再跑一遍WDA。毕竟重启大法好。
4、在跑测试脚本对相应app进行测试时,一定要注意脚本里面'bundleId'和编译时设置的 bundleId 是一致的
我在跑的时候出现以下错误

另外注意编译一个工程文件 bundle id 必须是唯一的,可以自己命名。