背景:新到了mac,开始安装环境
第一步:安装brew
Homebrew官网:
Homebrew — The Missing Package Manager for macOS (or Linux)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
使用命令行时报错:
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 19 ms: Couldn't connect to server
【解决】到github上下载.pkg包安装,homebrew安装包地址:
Release 4.2.0 · Homebrew/brew · GitHub
Release 4.1.24 · Homebrew/brew · GitHub
安装 homebrew时的提示:
This package will install to:
⁃ /opt/homebrew on Apple Silicon
⁃ /usr/local/bin/brew and /usr/local/Homebrew on Intel
第二步:安装 命令行工具
Command Line Tools (CLT) are missing
You must install the Command Line Tools (CLT) before installing Homebrew by running xcode-select --install
from a Terminal.
按照提示执行xcode-select --install
已安装后提示:
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
第三步:安装python
mac自带的python版本是:
testmanzhang@TestMandeMBP ~ % python3 --version
Python 3.9.6
升级python:
brew upgrade python
提示:
Error: The following directories are not writable by your user:
/usr/local/opt
You should change the ownership of these directories to your user.
sudo chown -R testmanzhang /usr/local/opt
And make sure that your user has write permission.
chmod u+w /usr/local/opt
【解决】下载python安装包安装
添加Python环境变量:
vi ~/.zshrc
PATH="/Library/Frameworks/Python.framework/Versions/3.12/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12"
source ~./zshrc
获取pip安装包:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
安装pip:
python3 get-pip.py
zhangjiaxxx@zhangjixxxdeMBP ~ % pip --version
pip 23.3.1 from /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip (python 3.12)
第四步:安装setuptools
setuptools · PyPI
安装setuptools,提示已经安装:
zhangjiaxxx@zhangjixxxdeMBP ~ % pip install setuptools
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (69.0.2)
zhangjiaxxx@zhangjixxxdeMBP ~ % brew list
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:02180ca8b8295422ae84921bcf034b7ee8ce5575488bd5e6a37a192e53cd5d34
######################################################################### 100.0%
==> Pouring portable-ruby-3.1.4.el_capitan.bottle.tar.gz
第五步:安装node
安装node时报错:
zhangjiaxxx@zhangjixxxdeMBP ~ % brew install node
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
Error: The following directories are not writable by your user:
/usr/local/opt
You should change the ownership of these directories to your user.
sudo chown -R zhangjiaxxx /usr/local/opt
And make sure that your user has write permission.
chmod u+w /usr/local/opt
【解决】按照提示执行以上两行命令,中间输入一次密码。
执行:brew install node
过程:先安装依赖,之后再安装node
==> Installing node
==> Pouring node--21.3.0.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/node/21.3.0: 2,233 files, 64.5MB
==> Running brew cleanup node
...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew
).
node -v
v21.3.0
安装成功
npm自动安装好了:
zhangjiaxxx@zhangjixxxdeMBP ~ % npm -v
10.2.4
第六步:安装Carthage
功能介绍:
https://juejin.cn/post/6844904002505670663
brew install carthage
carthage version 查看版本,安装成功。
carthage官网:
carthage — Homebrew Formulae
Carthage 使用方法 | Notes
连接iPhone的时候弹出提示:
需要更新软件才能连接xxx的iPhone
您要现在下载并安装此更新吗?
使用此软件须接受软件更新时所附带的原始“软件许可协议”
点击:安装
第七步:安装appium:
安装appium:
zhangjiaxxx@zhangjixxxdeMBP ~ % npm i --location=global appium
npm WARN deprecated typedoc-plugin-resolve-crossmodule-references@0.3.3: Upgrade to typedoc >= 0.24 and remove typedoc-plugin-resolve-crossmodule-references from your dependencies
added 490 packages in 45s
61 packages are looking for funding
run npm fund
for details
npm notice
npm notice New patch version of npm available! 10.2.4 -> 10.2.5
npm notice Changelog: Release v10.2.5 · npm/cli · GitHub
npm notice Run npm install -g npm@10.2.5 to update!
npm notice
zhangjiaxxx@zhangjixxxdeMBP ~ % appium -v
2.2.3
第八步:安装驱动
安装驱动:
appium driver install --source=npm appium-xcuitest-driver
appium driver install mac2
appium driver listzhangjiaxxx@zhangjixxxdeMBP ~ % appium driver list
✔ Listing available drivers
- xcuitest@5.12.0 [installed (npm)]
- mac2@1.8.9 [installed (npm)]
- uiautomator2 [not installed]
- espresso [not installed]
- safari [not installed]
- gecko [not installed]
- chromium [not installed]
第九步:安装插件
安装插件:
appium plugin install images
第十步:安装appium-python-client
pip install Appium-Python-Client
第十一步:安装appium-doctor
npm i --location=global appium-doctor
官方建议:npm install @appium/doctor --location=global
testmanzhang@TestMandeMBP site-packages % npm i --location=global appium-doctor
npmWARNdeprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npmWARNdeprecated authorize-ios@1.2.1: Moved into appium
added 266 packages in 19s
27 packages are looking for funding
run `npm fund` for details
第十二步:查看环境
appium-doctor --ios
testmanzhang@TestMandeMBP / % appium-doctor --ios
第十三步:安装Xcode
在app store上安装即可
第十四步:安装appium inspector
进入页面选择需要的版本:Releases · appium/appium-inspector · GitHub 手动安装即可
appium inspector打开报错解决方法:
1、Control+Click the Appium Inspector icon in the Applications Finder folder and choose Open.
2、You'll be presented with the dialog below. Just click Open and Appium Inspector should launch.
第十五步:安装ffmpeg
ffmpeg官网:
Download FFmpeg
FFmpeg(全称:Fast Forward Mpeg),名称来自MPEG视频编码标准。FFmpeg是一套用来处理视频和音频的开源工具库。它提供了录制、转换、流化音视频以及后期处理的完整解决方案。有很高的质量和可移植性。
介绍:
FFmpeg音视频处理 - 知乎
brew install ffmpeg
第十六步:安装ios-deploy
brew install ios-deploy
command-not-found.com – idevicesyslog
brew install libimobiledevice
之后可以查看实时日志:
idevicesyslog
结束时control +c
第十七步:安装ios-webkit-debug-proxy
brew install ios-webkit-debug-proxy
第十八步:安装authorize-ios
npm install authorize-ios
authorize-ios - npm Package Health Analysis | Snyk
npm ERR! A complete log of this run can be found in: /Users/zhangjiaxxx/.npm/_logs/2023-12-07T11_48_08_426Z-debug-0.log
上面这个文件可以定时清除以免占用空间
以上necessary的全部部分都安装完成。下面安装可选的安装项:
第十九步:安装idb
idb用法:
const idb = IDB({
udid: deviceUdid,
});
await idb.connect();
const deviceInfo = await idb.describeDevice();
await idb.disconnect();
在调用idb实例之前要先调用connect
brew tap facebook/fb //安装失败后关掉终端重开
brew install idb-companion
pip3.6 install fb-idb
注:安装idb需要翻墙
idb使用介绍:Facebook - idb初识 - 简书
例如,idb --udid log
idb --udid launch com.glazxxx.ios
第二十步:安装opencv和opencv4nodejs
brew install opencv
brew install cmake
npm i -g node-gyp
npm i -g opencv-build
npm i -g opencv4nodejs
注:在bash_profile中添加环境变量export OPENCV4NODEJS_DISABLE_AUTOBUILD=1后安装opencv-build成功,在bash_profile中添加之后要执行source ~/.bash_profile让其生效
安装opencv4nodejs之前要安装opencv-build,安装opencv-build之前要设置export OPENCV4NODEJS_DISABLE_AUTOBUILD=1 环境变量
opencv4nodejs 踩坑 - 简书
安装opencv4nodejs成功!
第二十一步:安装set-simulator-location
作用是设置模拟器的位置,例如,经纬度、位置等
GitHub - MobileNativeFoundation/set-simulator-location: CLI for setting location in the iOS simulator
brew install lyft/formulae/set-simulator-location
$ set-simulator-location -c 37.7765 -122.3918
$ set-simulator-location -q Lyft HQ San Francisco
$ set-simulator-location -q Lyft HQ San Francisco -s iPhone X
第二十二步:安装applesimutils
brew tap wix/brew
brew install applesimutils
applesimutils用于Apple模拟器的utils集合,Detox使用它与模拟器进行通信
第二十三步:安装mjpeg-consumer
npm i -g mjpeg-consumer
至此Appium相关环境全部安装完成,可以执行appium-doctor --ios 进行检查