一、準備工具
1. 使用bash作為SHELL
打開終端(Terminal),輸入下方命令,之后不再贅述,
$ chsh -s /bin/bash
- 檢驗
$ echo $SHELL

2. 安裝Homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- 中國境內加速安裝可參考:HomebrewCN
-
后續使用推薦換源,參考操作: Homebrew倉庫URL源替換方法
-
若習慣圖形化界面可安裝Cakebrew:
brew install cakebrew
-
- 檢驗
$ brew -v
3. 安裝Python3.6和Java8
$ brew update
$ brew install python@3.6
$ brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
此處安裝Python3.6的目的是為了安裝pip3.6,便于之后使用,
多版本Python管理參考:Mac安裝指定Python版本和指定庫版本并且隨意切換版本
- 檢驗
$ python3 -V && java -version
4. 安裝14版本Node
強烈建議避免安裝15版本,
$ brew install node@14
- 此外,中國境內推薦安裝cnpm(npm的中國鏡像版,與npm通用)
$ npm install cnpm -g --registry=https://registry.npm.taobao.org
- 檢驗
$ node -v && npm -v
5. 安裝Android Studio和Xcode
自行選擇,自行安裝,
- Android Studio: https://developer.android.com/studio
- 根據專案需要選擇SDK版本
- Xcode:https://developer.apple.com/download/
- Mac平臺可直接從App Store上獲取
- 完成Xcode安裝后,需額外安裝命令列工具
$ xcode-select --install $ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer #可選項,指定Xcode版本,用于Mac上安裝了多個Xcode的情況
二、安裝軟體、模塊
1. 配置環境變數
(1) JAVA_HOME
$ echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.bash_profile
$ source ~/.bash_profile
- 檢驗
$ echo $JAVA_HOME
(2) ANDROID_HOME
$ echo 'export USER_HOME=$(eval echo ~$user)' >> ~/.bash_profile
$ echo 'export ANDROID_HOME=$USER_HOME/Library/Android/sdk' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/platform-tools:$PATH' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/platform-tools/bin:$PATH' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/tools:$PATH' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/tools/bin:$PATH' >> ~/.bash_profile
$ echo 'export BUILDTOOLS_VERSION=$(eval echo `ls $ANDROID_HOME/build-tools`)' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/build-tools/$BUILDTOOLS_VERSION:$PATH' >> ~/.bash_profile
$ echo 'export PATH=$ANDROID_HOME/build-tools/$BUILDTOOLS_VERSION/bin:$PATH' >> ~/.bash_profile
$ source ~/.bash_profile
- 檢驗
$ echo $ANDROID_HOME
2. 繼續安裝
此處省略檢驗步驟,有需要可自行檢查軟體或模塊的安裝情況,
(1) Homebrew安裝部分
$ sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
$ sudo xcodebuild -license accept
$ brew install carthage libimobiledevice ios-deploy cmake wix/brew/applesimutils ios-webkit-debug-proxy gstreamer ifuse lyft/formulae/set-simulator-location
$ brew install --cask osxfuse
$ brew tap facebook/fb
$ brew install idb-companion
$ pip3.6 install fb-idb
(2) npm安裝部分(可選擇用cnpm代替)
$ echo 'export OPENCV4NODEJS_DISABLE_AUTOBUILD=1' >> ~/.bash_profile
$ npm install -g appium wd appium-doctor webpack opencv4nodejs mjpeg-consumer ffmpeg
(3) 補充
下載并配置Bundletool
- 下載
bundletool.jar:https://github.com/google/bundletool/releases- 加速鏡像
- 將下載的檔案重命名為
bundletool.jar(注意“.jar”為后綴名) - 創建bundle-tool檔案夾:
$ mkdir ~/Library/Android/sdk/bundle-tool - 將
bundletool.jar檔案復制到上方的地址- 在
訪達中使用快捷鍵Command+Shift+G - 輸入
~/Library/Android/sdk/bundle-tool后按回車鍵 - 復制檔案
- 賦予檔案可執行權限:
$ chmod +x bundletool.jar - 在
- 添加環境變數
$ echo 'export PATH=$ANDROID_HOME/bundle-tool:$PATH' >> ~/.bash_profile $ source ~/.bash_profile
三、確認
$ appium-doctor
通過appium-doctor可以確認所需軟體、模塊是否成功安裝,以便作出針對性處理,
若一切順利,則系統檢測通過,并反饋Everything looks good, bye!

- 開啟appium服務
$ appium
至此,Appium在macOS上的部署已完成,Congratulations! 🍺🍺🍺
參考資料:
[1]Krishna Chetan.Setup Appium on Mac OS for Android and iOS App Automation [EB/OL].https://krishnachetan.medium.com/setup-appium-on-mac-1e06f1178427, 2020-10-21/2021-4-7
[2]cuma2369.bash 獲取環境變數_如何從Bash中的變數中的用戶名獲取用戶的主目錄? [EB/OL].https://blog.csdn.net/cuma2369/article/details/107668958, 2020-07-21/2021-4-7
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/273749.html
標籤:其他
上一篇:2021-04-07
