Mac-appium iOS真机测试

1、安装依赖库

brew install libimobiledevice --HEAD


npm install -g ios-deploy



注:如果没有安装 libimobiledevice,会导致Appium无法连接到iOS的设备,所以必须要安装,如果要在iOS10+的系统上使用appium,则需要安装ios-deploy


安装出现问题

DEEPbing:~ ewrwrw$ npm install -g ios-deploy

> [email protected] preinstall /usr/local/lib/node_modules/ios-deploy

> ./src/scripts/check_reqs.js && xcodebuild

stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! [email protected] preinstall: `./src/scripts/check_reqs.js && xcodebuild`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the [email protected] preinstall script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/xiaoyezi/.npm/_logs/2018-05-14T12_32_53_678Z-debug.log

解决:原因xcode升级,文件默认路径改变:

运行:sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

在执行:sudo npm install -g ios-deploy --unsafe-perm=true


2、如果已安装appium-doctor忽略

npm install appium-doctor -g


3、
安装后执行

appium-doctor --ios


指令,可以查看与iOS相关配置是否完整,下图是全部配置都成功,如果有那一项是打叉的,则进行安装就可以了

例如:

brew install carthage

4、更新Appium中的WebDriverAgent

WebDriverAgent下载最新版本的WebDriverAgent进入下载后的 WebDriverAgent文件执行 命令
$ cd /Users/XXXX/git/WebDriverAgent
$ mkdir -p Resources/WebDriverAgent.bundle$ sh ./Scripts/bootstrap.sh

直接用Xcode打开 WebDriverAgent.xcodepro文件配置 WebDriverAgentLibWebDriverAgentRunner的证书

添加team

如果是免费版的个人证书,还需要修改下WebDriverAgent的BundleID,随便加点后缀,只要不跟其他人的重名就好 (注:一定设置好这个,有开发者证书就不需要了)

OK配置完成,运行