Install Appium on Mac OS for iOS and setup

Shivam Tiwari
4 min readMar 18, 2021

--

Some Simple steps in which you can really get this sh!t setup .

Automation Testing or Test Automation is the process of using the assistance of tools, scripts, and software to perform test cases by repeating pre-defined actions. It allows testers to create a robust framework with an automation script, which can be run during functional or regression testing to save time as well as cost. There is ’n’ number of testing tools available for mobile app automation, but ‘Appium’ is most widely used for test automation.

Here, I’ll give you 3 easy simple steps to configure Appium on Mac OS.

Setting up Mac OS for Appium Automation Testing is a bit difficult task if you are new to the Mac system. But if you are familiar with commands on the terminal, then it will be easy to complete the setup.

Install Java JDK latest version

First, download Java JDK from the below URL and install it (I recommend to use JDK 8 or higher version of JDK, as they have more compatibilities).

Setup Java Home Path using terminal

Type below command on terminal:

open -e .bash_profile

It’ll open the bash profile in edit mode. Now, you can edit Java_home, Android _home with the below commands:

Copy these commands and replace the username with your machine’s username and JDK version and paste these on bash profile:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

export ANDROID_HOME=/Users/<username>/Library/Android/sdk

export PATH=$/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/bin:$PATH

export PATH=”/Users/ <username> /Library/Android/sdk/platform-tools”:$PATH

and then save it from File > Save and close the bash profile text editor. Now, your Java and Android home environment variable has been updated.

Setup Appium on Mac OS

Step 1: Install all the pre-requisites for Appium

  • Install the latest Xcode Desktop version 12.3 or higher.
  • Install Xcode command line (use Command: Xcode-select — install)
  • Install Homebrew with the below command:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • brew install npm
  • npm install carthage
  • npm install -g appium
  • npm install appium-doctor -g
  • sudo gem install xcpretty
  • brew install libimobiledevice –HEAD
  • npm install -g ios-deploy

Step 2: Download Appium Desktop and install it

Now, download the latest Appium desktop version from the below link and install it.

Or, here you can download Appium-mac-1.20.2.dmg directly and install.

Step 3: Setting up WebdriverAgent in XCode

This is a very important setup and needs to be done very carefully, otherwise, you will not be able to launch the Appium app.

(i) Open the terminal and go to the WebDriverAgent folder within the Appium installation directory. It will be found at the below path:

Right click on Appium desktop > Contents /Resources/app/node_modules/Appium/node_modules/appium-webdriveragent

Now, run the below mention two commands:

1) mkdir -p Resources/WebDriverAgent.bundle
2) ./Scripts/bootstrap.sh -d

(ii) Connect your iPhone with the system and open WebDriverAgent.xcodeproj in Xcode. Now select the WebDriverAgentLib and WebDriverAgentRunner targets in XCode, and select the “Automatically manage signing” checkbox in the “General” tab, and then select your Development Team. This should also auto select Signing Certificate.

Here, You have to set up an Apple developer account with XCode to select the team.

XCode maybe fails to create a provisioning profile for the WebDriverAgentRunner automatically, so it needs a manual change to the bundle id for the target. Go into the “Build Settings” tab, and change the “Product Bundle Identifier” from com.facebook.WebDriverAgentRunner to something unique that Xcode will accept: like — com.abcxyz.WebDriverAgentRunner or whatever suits you.

Similarly, setup WebDriverAgentLib and Integration App in Xcode. Then build the integration app. To run the Integration App, an Apple id is required, and it should be trusted on a real iPhone device from:

Settings > General > Device Management.

Here click on the Apple id to trust it.

Now close Xcode, and quit Xcode then run below test command with udid within WebDriverAgent destination on terminal:

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=<udid>’ test

If everything is set up properly, then you will get a terminal like below after running the above command:

Launch Appium on Mac OS X

Now, launch the Appium app from ‘Application’ and start the Appium Server.

and click on the search icon on the right top to set up the desired capabilities.

Desired capabilities JSON Representation, You can edit the below information according to your app and use it as desired capabilities.

{
"platformName": "iOS",
"deviceName": "iPhone 11",
"platformVersion": "14.4",
"app": "/Users/shivamtiwari/Downloads/<appname>.app",
"bundleId": "com.shivamtiwari.testapp",
"udid": "0E5F6579-14F0-4A74-A121-7423487B4DB0",
"automationName": "XCUITest"
}

By using the above steps, click on ‘Start Session’ and this will start to install the app on the device and UI will be displayed in Appium Inspector also, here you can find the locators and start writing an automation test script.

--

--

Shivam Tiwari
Shivam Tiwari

Written by Shivam Tiwari

A programmer , a learner , enthusiast , who always searches new technology keen to learn new things and technology

No responses yet