idevice
Files & Apps

AFC

Read and write files through Apple File Conduit.

AFC exposes file operations through AfcClient. The normal AFC service uses com.apple.afc; AfcClient::new_afc2 connects to com.apple.afc2.

Use It For

  • Listing directories.
  • Reading and writing files.
  • Creating and removing paths.
  • Reading file and filesystem metadata.

Feature Flag

Cargo.toml
[dependencies]
idevice = { version = "0.1.64", features = ["usbmuxd", "afc"] }

Service Names

PathValue
Normal AFCcom.apple.afc
AFC2com.apple.afc2
RSD AFCcom.apple.afc.shim.remote

Rust Example

src/main.rs
use idevice::{
    IdeviceService,
    afc::{AfcClient, opcode::AfcFopenMode},
};

let provider = first_provider().await?;
let mut afc = AfcClient::connect(&provider).await?;

for entry in afc.list_dir("/").await? {
    println!("{entry}");
}

let mut file = afc.open("/path/on/device", AfcFopenMode::RdOnly).await?;
let bytes = file.read_entire().await?;
file.close().await?;

CLI Equivalent

Terminal
idevice-tools afc list /
idevice-tools afc download /path/on/device ./local-file
idevice-tools afc upload ./local-file /path/on/device
idevice-tools afc info /path/on/device

Common Errors

ErrorWhat to check
Permission deniedThe path is outside the exposed AFC jail.
File open failureCheck the path and AfcFopenMode.
Missing pairing filePair the device before connecting through Lockdown-started AFC.

Source

On this page