I’m working on a macOS app that sends commands to the user’s shell environment for communicating with a connected iOS device through xcrun
. At one point in the app’s workflow, I need to check if a certain app is running to decide if I want to kill the process or not. However, when executing the following command I’ve run into issues:
$ xcrun devicectl device info processes --device 00008210-0015358E1EE8502E
11:18:56 Acquired tunnel connection to device.
11:18:56 Enabling developer disk image services.
11:18:56 Acquired usage assertion.
ERROR: An error occurred while communicating with a remote process. (com.apple.dt.CoreDeviceError error 3 (0x03))
--------------------------------------------------------------------------------
ERROR: The connection was invalidated. (com.apple.Mercury.error error 1001 (0x3E9))
XPCConnectionDescription = <RemoteXPCPeerConnection 0x600003e4c410> { <remote connection: 0x1340325c0> { type = preconnected, state = canceled, remote service name = (null), server mode = 0, protocol version number = 1, protocol feature flags = 0x6, local service version = 0, remote service version = 0, traffic class = 0, (root, reply) helo received = (1, 1), next msg id = 5, first msg id = 1, send in progress = 0, preexisting socket = -1 }
The connection seems to be invalidated as soon as I try to access the device’s processes while an app that I’ve installed onto the device through Xcode is running. When I execute the same command without the installed app running I get the expected list of processes:
$ xcrun devicectl device info processes --device 00008210-0015358E1EE8502E
11:20:05 Acquired tunnel connection to device.
11:20:05 Enabling developer disk image services.
11:20:05 Acquired usage assertion.
PID Executable Path
---- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 /sbin/launchd
31 /usr/libexec/UserEventAgent
32 /usr/libexec/logd
33 /usr/libexec/runningboardd
34 /System/Library/CoreServices/SpringBoard.app/SpringBoard
...
I’ve tried looking online for resources relating to the com.apple.Mercury.error error that I’m facing when running the app but I haven’t found any information relating to the problem I’m facing here.
Some info:
- iPhone 13 connected to a MacBook through USB
- The error is only reproducible when using an app that I’ve installed onto my iOS device through
xcrun
, not just any app on my iOS device
I’ve expected the command to list a device’s processes to be independent on a debug app running on the device at the time or not, and unfortunately the only time in my macOS app’s lifecycle where it is important to run this command is exactly when the debug app is running on the device.
Any advice for how to debug this would be appreciated!