Take a Screenshot
Save a screenshot from the connected device.
Use ScreenshotService for the older screenshot service path:
This example uses the first_provider() helper from the examples overview.
use idevice::{IdeviceService, screenshotr::ScreenshotService};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let provider = first_provider().await?;
// screenshotr is the older lockdown service for screenshot capture.
let mut screenshots = ScreenshotService::connect(&provider).await?;
let image = screenshots.take_screenshot().await?;
tokio::fs::write("./screenshot.png", image).await?;
Ok(())
}Add the needed features:
[dependencies]
idevice = { version = "0.1.64", features = ["usbmuxd", "screenshotr"] }
tokio = { version = "1", features = ["fs", "macros", "rt-multi-thread"] }The CLI screenshot command is a useful compatibility wrapper. It tries the newer
DVT/CoreDevice path first, then falls back to screenshotr:
idevice-tools screenshot ./screenshot.pngFor the older service path, make sure the required Developer Disk Image is mounted on devices that need it.