Mac OS搭建appium-ios真机环境一. 安装ruby(如已存在则无需安装)1. 安装rvmcurl -L https://get.rvm.io | bash -s stable2. 载入rvm环境source ~/.rvm/scripts/rvm3. 检查rvm安装情况rvm -v4. 安装rubyrvm list knownrvm install 2.6.0#等待下载(途中需要按回车确定安装路径、还要输入密码)、编译。完成之后Ruby、Ruby Gems就安装好了查询已安装rubyrvm list卸载已安装版本(如无,则无需卸载),设置ruby版本rvm remove [旧版本号]rvm 2.6.0 -defaultrvm -vgem -v5. 更换ruby源gem sources -l #检测ruby源gem sources –remove https://rubygems.org/ #移除ruby源(根据检测结果)gem sources –add https://gems.ruby-china.com至此,ruby安装完成二. 配置安装appium各依赖项1. 安装homebrew/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"2. 安装libimobiledevicebrew install libimobiledevice –HEAD3. 安装carthage、node、npmbrew install carthagebrew install nodebrew install npm4. 安装ios-deploy、xcprettynpm install -g ios-deploygem install xcpretty5. 安装appium-desktop、appium-doctor从GitHub下载appium-xxx.dmg,安装npm install -g appium-doctorappium-doctor –ios至此,已完成appium-desktop及其依赖相关安装三. 安装WebDriverAgent到github下载最新版本的[WebDriverAgent][1]cd 进入下载后的WebDriverAgent文件执行 ./Scripts/bootstrap.sh执行成功后移动到appium安装目录的appium-xcuitest-driver目录下,删除旧WebDriverAgent目录即:sudo rm -rf WebDriverAgentln -s ~/WebDriverAgent将编译好的WebDriverAgent移动到appium-xcuitest-driver目录####其实此时应已经可以使用appium-desktop直接用Xcode打开WebDriverAgent.xcodepro文件配置WebDriverAgentLib和WebDriverAgentRunner的证书 连接并选择自己的iOS设备,然后按Cmd+U,或是点击Product->Test问题1:安装ruby时,更改ruby-china源报错解决方法:ruby-china源域名已更换,为https://gems.ruby-china.com,而非org问题2:执行brew install libimobiledevice –HEAD 报错Error Message:Requested ’libusbmuxd >= 1.1.0’ but version of libusbmuxd is 1.0.10解决办法:brew uninstall –ignore-dependencies libimobiledevicebrew uninstall –ignore-dependencies usbmuxd##以上执行失败均无关系brew unlink usbmuxdbrew install –HEAD usbmuxdbrew link usbmuxd#执行以上命令后,重新执行以下命令可成功安装brew install libimobiledevice –HEAD问题3:执行 npm install -g ios-deploy报错(存在于多个xcode版本的情况下)错误信息:xcode-select:error:tool ‘xcodebuild requires Xcode解决方法:切换xcode路径的方法为:sudo xcode-select –switch /Applications/Xcode.app/Contents/Developer(xcode路径)问题4:安装opencv4nodejs、fbsimctl、applesimutils失败解决办法:安装opencv4nodejs:1. 使用npm代替brew:brew install cmakenpm install -g opencv4nodejs2. 安装fbsimctl:brew tap facebook/fbbrew install fbsimctl3. 安装applesimutil:brew tap wix/brewbrew install applesimutil