Appium iOS Device API

3.1.11 · active · verified Tue Apr 21

appium-ios-device is a robust Node.js library providing a comprehensive API for advanced, low-level programmatic interaction with iOS devices. It acts as a direct, pure JavaScript/TypeScript rewrite of the `libimobiledevice` C library, enabling Appium and other tools to communicate with iPhones, iPads, and iPods over `usbmuxd` without relying on macOS-specific tools like Xcode for basic operations. This package facilitates a wide array of functionalities, including retrieving detailed device information (OS version, name, device time), establishing secure port connections, and managing various iOS services such as syslog monitoring, web inspector sessions, app installation proxying, and location simulation. A key differentiator is its `Xctest` class, which allows invoking pre-installed XCUITest applications on devices without needing a full Xcode environment on the host machine. Currently at version 3.1.11, the library undergoes active development with frequent patch and minor releases, reflecting ongoing maintenance and adaptation to new iOS versions and underlying dependencies. While primarily used and tested within the `appium-xcuitest-driver` on macOS, it offers partial functionality on other platforms, though full capabilities often necessitate specific developer image mounts or a macOS host with Xcode.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to discover and retrieve basic information for all currently connected iOS devices via USB.

import { utilities } from 'appium-ios-device';

async function getAndDisplayConnectedDevices() {
  console.log('Attempting to discover connected iOS devices...');
  try {
    const devices = await utilities.getConnectedDevices();

    if (devices.length === 0) {
      console.log('No iOS devices found connected via USB.');
      console.log('Please ensure your device is connected, unlocked, and trusted the computer.');
      return;
    }

    console.log(`Successfully found ${devices.length} iOS device(s):`);
    for (const udid of devices) {
      console.log(`\n  Device UDID: ${udid}`);
      const deviceInfo = await utilities.getDeviceInfo(udid);
      console.log(`  Name: ${deviceInfo.deviceName}`);
      console.log(`  iOS Version: ${deviceInfo.productVersion}`);
      console.log(`  Product Type: ${deviceInfo.productType}`);
      console.log(`  Build Version: ${deviceInfo.buildVersion}`);
      // More properties are available in deviceInfo object
      // e.g., deviceInfo.modelNumber, deviceInfo.serialNumber
    }
    console.log('\nDiscovery complete.');

  } catch (error) {
    console.error('Failed to communicate with iOS devices. Ensure usbmuxd is running and devices are connected.', error);
    console.error('Common issues: Older Node.js version, unmounted developer image (for advanced services).');
  }
}

getAndDisplayConnectedDevices();

view raw JSON →