Control an iPhone from Terminal with xcrun devicectl
devicectl is Apple’s command line for CoreDevice, the device stack that came with Xcode 15 and iOS 17. It installs, launches and inspects apps on an iPhone without opening Xcode, and it writes JSON a script can read. Every command and flag below comes from the help of devicectl 518.27, the version in Xcode 26.4. The output is from an iPhone 16 on iOS 18.3.1, with its identifiers replaced.
Check that you have it
xcrun -f devicectlxcrun devicectl --version/Applications/ Xcode.app/ Contents/ Developer/ usr/ bin/ devicectl518.27If xcrun answers unable to find utility "devicectl", check which Xcode installation your command-line tools use. Select an installation of Xcode 15 or later:
sudo xcode-select -s /Applications/ Xcode.appOn our Mac, every devicectl command first printed two lines, Failed to load provisioning paramter list due to error: ... "No provider was found." and devicectl manage create` may support a reduced set of arguments., and then ran and exited 0. Both go to stderr, so 2>/dev/null hides them.
Find the iPhone
xcrun devicectl list devicesIt prints one row per device it knows, with five columns: Name, Hostname, Identifier, State and Model. Pick the columns you want with --hide-default-columns and --columns:
xcrun devicectl list devices --hide-default-columns --columns Name --columns State --columns ModelName State Model------ ------------------ ----------------------iPhone available (paired) iPhone 16 (iPhone17,3)The State column says what devicectl can do with each device right now:
connected: a tunnel to the phone is open.available (paired): the phone is paired and reachable, with no tunnel open. The next command that needs it opens one, and printsAcquired tunnel connection to device.unavailable: the phone was paired once and can’t be reached now.
Every command that acts on a phone takes --device (-d). It accepts the Identifier column, the ECID, the serial number, the UDID, the phone’s name or its DNS name. Use the Identifier. A name has to match exactly. A curly apostrophe (’) in a name does not match a typed ’.
--filter takes an NSPredicate over the column names or the JSON field names:
xcrun devicectl list devices --filter "hardwareProperties.marketingName == 'iPhone 16'"--columns '*' prints every column, and --hide-headers drops the header rows.
The Identifier isn’t the UDID
The Identifier is CoreDevice’s own UUID, in the form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. xcodebuild -destination id=... and xcrun xctrace list devices use the UDID, in the form XXXXXXXX-XXXXXXXXXXXXXXXX on recent iPhones. The UDID is in the JSON (see Read JSON):
xcrun devicectl list devices -q --json-output devices.jsonjq -r '.result.devices[] | select(.connectionProperties.pairingState == "paired") | [.identifier, .hardwareProperties.udid] | @tsv' devices.jsonRead the phone’s details
xcrun devicectl device info details --device <identifier>Current device information:• identifier: <identifier>▿ hardwareProperties: • deviceType: iPhone • marketingName: iPhone 16 • platform: iOS • productType: iPhone17,3 • reality: physical • udid: <UDID>▿ deviceProperties: • bootState: booted • ddiServicesAvailable: true • developerModeStatus: enabled • name: iPhone • osBuildUpdate: 22D72 • osVersionNumber: 18.3.1▿ connectionProperties: • pairingState: paired • transportType: localNetwork • tunnelState: connectedThat is a trimmed excerpt; the full answer also lists the hardware, the hostnames and the phone’s capabilities. It took 4.9 s, including opening the tunnel. Three fields answer most setup questions:
developerModeStatussays whether Developer Mode is on, without picking up the phone.ddiServicesAvailablesays whether the Developer Disk Image services are mounted. devicectl turns them on when a command needs them, and printsEnabling developer disk image services.transportTypeislocalNetworkwhen the tunnel runs over Wi-Fi, as it did here.
Two more read the phone’s state:
xcrun devicectl device info lockState --device <identifier>Current device lock state:• deviceIdentifier: <identifier>• passcodeRequired: true• unlockedSinceBoot: truepasscodeRequired: true means the phone is locked now. A UI test can’t drive a locked screen, so check this before a run.
xcrun devicectl device info displays --device <identifier>Current Displays:▿ 1: LCD (primary): • bounds: (0.0, 0.0, 1179.0, 2556.0) • currentOrientation: rot0 • pointScale: 3Main display backlight state: backlight is offMain display orientation: portrait, non-flat orientation: portrait, orientation not lockedInstall, launch and stop an app
Install a build
device install app takes an .app bundle signed for the phone. Build one for a device, then install it:
xcodebuild -scheme YourApp -destination 'generic/ platform=iOS' -derivedDataPath build buildxcrun devicectl device install app --device <identifier> build/ Build/ Products/ Debug-iphoneos/ YourApp.appList the apps on it
xcrun devicectl device info apps --device <identifier>Apps installed:Name Bundle Identifier Version Bundle Version------- ------------------- ------- --------------YourApp com.example.yourapp 1.0 1By default it lists only apps a developer installed. --include-default-apps adds Apple’s, --include-app-clips adds App Clips, --include-all-apps lists everything, and --bundle-id <id> lists one app.
Launch it
xcrun devicectl device process launch --device <identifier> com.example.yourapp--terminate-existingstops a running copy of the app first.--consoleconnects the app’s stdout and stderr to your terminal and waits for it to exit. It needs Xcode 16 or later.--payload-url <url>hands the app a URL to open as it launches, such as a deep link.-e '<json>'(--environment-variables) sets environment variables, as a JSON object of strings.--start-stoppedlaunches it suspended, waiting for a debugger.--no-activatelaunches it without bringing it to the foreground.
Any arguments after the bundle ID go to the app. You can also set environment variables in your shell with the DEVICECTL_CHILD_ prefix, and the app gets them without it. -e replaces those.
DEVICECTL_CHILD_API_BASE=https://staging.example.com \ xcrun devicectl device process launch --device <identifier> --terminate-existing --console com.example.yourappStop it
device process terminate takes a process ID, not a bundle ID. List the processes, find the app’s, then stop it:
xcrun devicectl device info processes --device <identifier> -q --json-output processes.jsonpid=$(jq -r '.result.runningProcesses[] | select(.executable | contains("/ YourApp.app/ ")) | .processIdentifier' processes.json)xcrun devicectl device process terminate --device <identifier> --pid "$pid"The process list is long: 450 processes on this phone, from launchd at PID 1 to SpringBoard. Each one is an executable path:
PID Executable Path----- ----------------------------------------------------------34 / System/ Library/ CoreServices/ SpringBoard.app/ SpringBoard67 / usr/ libexec/ backboarddterminate sends SIGTERM; add --kill for SIGKILL. The same family has signal --signal <name>, suspend, resume and sendMemoryWarning, which sends your app a memory warning on real hardware.
Uninstall it
xcrun devicectl device uninstall app --device <identifier> com.example.yourappCopy files to and from an app
The file commands name a domain and, for an app’s container, the bundle ID. The domains are temporary, appDataContainer, appGroupDataContainer and systemCrashLogs.
List what’s in the app’s Documents folder:
xcrun devicectl device info files --device <identifier> \ --domain-type appDataContainer --domain-identifier com.example.yourapp --subdirectory DocumentsPull a database off the phone:
xcrun devicectl device copy from --device <identifier> \ --domain-type appDataContainer --domain-identifier com.example.yourapp \ --source Documents/ app.sqlite --destination ./ app.sqlitePush a fixture onto it:
xcrun devicectl device copy to --device <identifier> \ --domain-type appDataContainer --domain-identifier com.example.yourapp \ --source ./ fixtures/ app.sqlite --destination Documents/ app.sqlitecopy to skips files that haven’t changed and takes --source more than once. For a directory, --remove-existing-content true clears the destination first.
Read JSON, not the table
devicectl’s help says the printed table is for people and can change between releases. The supported interface for a script is the file --json-output (-j) writes. Add -q to keep the table off your terminal.
xcrun devicectl device info lockState --device <identifier> -q --json-output lock.json{ "info": { "commandType": "devicectl.device.info.lockState", "jsonVersion": 3, "outcome": "success", "version": "518.27" }, "result": { "deviceIdentifier": "<identifier>", "passcodeRequired": true, "unlockedSinceBoot": true }}That’s trimmed: info also holds the arguments and the environment. When a command fails, it exits 1, info.outcome is failed, and an error object holds the code, the domain (com.apple.dt.CoreDeviceError) and userInfo.NSLocalizedDescription.
Stop a script when the phone is locked:
jq -e '.result.passcodeRequired == false' lock.json >/dev/null || { echo "Unlock the iPhone first" >&2; exit 1; }List the paired iPhones with their name, model, iOS version and tunnel:
jq -r '.result.devices[] | select(.hardwareProperties.platform == "iOS" and .connectionProperties.pairingState == "paired") | [.deviceProperties.name, .hardwareProperties.marketingName, .deviceProperties.osVersionNumber, .connectionProperties.tunnelState] | @tsv' devices.jsoniPhone iPhone 16 18.3.1 disconnectedSome devices in the list have no name. A test() on one stops jq with null (null) cannot be matched, as it is not a string, so give it a default: select((.deviceProperties.name // "") | test("iPhone")).
Pass --timeout (-t) in scripts, too. A listing or a launch can hang while CoreDevice brings up a tunnel, and -t 30 makes the command fail after 30 s instead of waiting.
The errors, and what fixes them
xcrun: error: unable to find utility "devicectl", not a developer tool or in PATH. Check which Xcode installation your command-line tools use. Run sudo xcode-select -s /Applications/.
ERROR: The specified device was not found. (Name: ...) (com.apple.dt.CoreDeviceError error 1000 (0x3E8)). The --device value matched nothing. Copy the Identifier from xcrun devicectl list devices. A typed name usually fails on the curly apostrophe.
ERROR: CoreDeviceService was unable to locate a device matching the requested device identifier. (DeviceIdentifier: ...) (com.apple.dt.CoreDeviceError error 1011 (0x3F3)). The phone is paired but out of reach: its State is unavailable. Plug it in, or put it on the same network as the Mac, unlock it and run the command again.
ERROR: The specified operation is not implemented on this device. (com.apple.dt.CoreDeviceError error 1 (0x01)) from process launch --console. --console needs Xcode 16 or later.
jq: error ... null (null) cannot be matched, as it is not a string. A device in the list has no name. Use (.deviceProperties.name // "").
devicectl and the older tools
- ios-deploy doesn’t work with iPhones on iOS 17 or later from Xcode 15 on.
device install appanddevice process launchreplace it. - libimobiledevice (
idevice_id,ideviceinstaller,idevicesyslog) still lists, installs and streams logs over the cable. devicectl 518.27 has no command that streams the phone’s log, soidevicesyslogor Console still does that job. xcrun xctrace list devicesprints names, iOS versions and UDIDs. On our Mac it listed the iPhone 16 under “Devices Offline” while devicectl listed it asavailable (paired). Trust devicectl’s State.xcrun simctlis the same kind of tool for simulators. devicectl is for real devices.
Where Mobster fits
Mobster calls devicectl for the same jobs: it installs your build on a USB iPhone with device install app, reads the apps on the phone with device info apps before a check, and reads lockState over USB or Wi-Fi. The screen itself is driven by WebDriverAgent, which device setup installs for you. Setup on a previously unused iPhone 16 took 5 min 26 s from install to helper ready, excluding Trust and Developer Mode.
Then mobster test --device <phone> runs your saved checks on the phone. Mobster checks their assertions (testing). Test an iOS app on a real iPhone from your Mac walks through it from the cable, and the AI agent guide shows an agent writing the checks.
Get Mobster for Mac. It sets up your iPhone and runs mobster test on it: free on any number of iPhones (AI runs on a supported AI plan, an API key or a model on your Mac).
Questions
What is xcrun devicectl?
Apple's command line for CoreDevice, the device stack that came with Xcode 15 and iOS 17. It lists devices, installs, launches and stops apps, copies files into app containers and reads device details, all without opening Xcode.
Does devicectl replace ios-deploy?
For install and launch, yes. ios-deploy doesn't work with iPhones on iOS 17 or later from Xcode 15 on, and devicectl does both jobs with flags for a console, environment variables and a launch URL.
How do I get JSON from devicectl?
Pass --json-output with a file path. devicectl writes info (the command, its version and the outcome) and result (the data) to that file. Its help says the file is the only supported interface for scripts; the printed table can change between releases.
Why does devicectl say the specified device was not found?
The --device value matched no phone. A name has to match exactly, including any curly apostrophe (’) in it. Copy the Identifier column from xcrun devicectl list devices instead.
Sources
- Apple Developer Forums: devicectl is new in Xcode 15 (DTS answer)
- Apple Developer Forums: devicectl --console arrives in Xcode 16 (DTS answer)
- React Native CLI #2610: replace ios-deploy with xcrun devicectl
- Appium forum: devicectl launch and process listing hang on iOS 17 with Xcode 15
- Mobster docs: device setup



