Running Appium on a Physical iOS Device

Liz Pantalone
3 min readJun 3, 2019

--

Building upon an introduction of Appium in Appium: Automated App Testing, using Appium to run tests on physical iOS devices is explained.

source: https://icdn2.digitaltrends.com/image/wwdc-ios-12-devices.jpg

Why not just test in simulators?
Using simulators is a great way to do initial functionality testing. Ultimately, though, when testing a feature, we want to test it under conditions as close as possible to its use case. Because of this, it’s really important to test our app on actual devices.

The day before we first launched the app I’m working on currently, it was discovered that testers (our co-workers helping us out to do a last minute test run before launch) with iPhone 6s were experiencing crashes, due to loading indicators overloading their memory. If we hadn’t tested on real devices, we never would have caught that before launch.

While we’re still in the very early stages of this version of the app, we have a clear picture of how it is used.

The majority of our iOS users are on iPhones (95%), and about 5% are on iPads. It’s important to have coverage on those most popular models and iOS versions.

First, here are two very great sources that have been used as a reference. If something in this wiki doesn’t make sense, there may very well be more color either here or here.

Setting up for real device testing
If you don’t have Homebrew installed, make that happen.
1. brew install libimobiledevice then brew install ios-deploy
2. You should already have Carthage from running on simulators, but if you don’t brew install carthage
3. Make sure the device is on (it helps to adjust settings so that it won’t lock/sleep) and plugged into your machine
4. If and when the phone and/or computer asks, allow them to ‘Trust’ the device/computer
5. Try running the app manually to the phone

Select your scheme, destination device, and press play.

It should load just as if it were being built on a simulator.

Setting Desired Capabilities

{ // these are capabilities for running on a physical iphone
platformName: ‘iOS’,
app: ‘path/to/your/app.app’, // Path to the native app
appPackage: ‘com.app.yourapp’, // Package name of the app
platformVersion: ‘12.2.1’, // OS platform version of the device
deviceName: ‘LiziPhone’, // device name of the mobile device
udid: ‘00000000000’, // found by running `instruments -s devices` in terminal
bundleID: ‘com.app.app’,
xcodeOrgId: ‘00000000’,
xcodeSigningId: ‘iPhone Developer’,
waitforTimeout: waitforTimeout,
commandTimeout: commandTimeout,
newCommandTimeout: 30 * 60000,
useNewWDA: true,
// showIOSLog: true,
// showXcodeLog: true,
automationName: ‘XCUITest’,
noReset: false,
},

Setting up WebDriverAgent for the Phone
You may have noticed WDAgent installing on simulators… we need to allow this to happen for devices
1. Find where Appium is installed which appium
2. cd path/where/appium/is/installed/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
3. mkdir -p Resources/WebDriverAgent.bundle
4. ./Scripts/bootstrap.sh -d
Essentially what you’ve just done is created a WebDriverAgent XCode project, which can be found at /path/to/appium/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj and opened in XCode
5. Once opened in XCode, you will need to modify both the WebDriverAgentLib and WebDriverAgentRunner Targets to automatically sign. If you have errors, check out the ‘Full Manual Configuration’ section of this

Running Tests in Appium on the Real Device
* You should be good to go at this point.
* Go back to XCode and open your app workspace and build on the phone
* Get your Appium server up and running
* Make sure your Desired Capabilities are set and the ones set for simulators are commented out
* Run your command in your terminal, e.g. npm run ios:tests

--

--