idevice

Overview

Copyable examples for common idevice tasks.

These examples are written for developers embedding idevice in an app or tool. Each page starts with the Rust API shape, then includes the matching CLI command when it is useful for testing your setup from a terminal.

The examples use this provider setup:

src/main.rs
use idevice::usbmuxd::{UsbmuxdAddr, UsbmuxdConnection};

async fn first_provider() -> Result<idevice::provider::UsbmuxdProvider, Box<dyn std::error::Error>> {
    // Respect USBMUXD_SOCKET_ADDRESS when it is set, otherwise use the platform default.
    let addr = UsbmuxdAddr::from_env_var()?;
    let mut usbmuxd = UsbmuxdConnection::new(addr.to_socket().await?, 0);

    // Ask usbmuxd for a connected device. Real apps should pick by UDID.
    let device = usbmuxd
        .get_devices()
        .await?
        .into_iter()
        .next()
        .ok_or("no devices connected")?;

    // Providers create new connections to the same device for each service.
    Ok(device.to_provider(addr, "my-app"))
}

For a real application, choose the device by UDID instead of blindly taking the first device.

The CLI tools use the first connected device by default. Use --udid when more than one device is connected:

Terminal
idevice-tools --udid <device-udid> <command>

For TCP/CoreDevice tunnel usage, pass both the device host and pairing file:

Terminal
idevice-tools --host <device-ip> --pairing-file ./pairing_file.plist <command>