Transferring data across mobile devices can be a daunting problem when those devices are in a DIL (Disconnected, Intermittent, Low bandwidth) environment where you do not want your device to transmit signals that could be detected. For small data packages it may make sense to use QR codes to transfer data across devices that are not connected. However; this type of solution is not scalable if you have large packets of data that need to be transferred. For larger amounts of data a laptop could be used as an intermediary between two devices. With an Android device the simplest way to do this would be to program the app on the device to dump the data to be transferred in an external file located in “My Files.” The Android device could then be plugged into a laptop where the device would be seen as an external mass storage device and the data could easily be retrieved and then transferred to another Android device. Unfortunately it is not this simple with iOS.

Communicating With an iOS Application through USB

The iOS mobile operating system limits the way in which Apple mobile devices (and therefore the applications on those devices) can communicate via the physical USB/Lightning connection. The typical portal through which data is transferred via a USB connection from a computer to an iOS mobile device (and vice-versa) is through the iTunes desktop application. The iTunes application accomplishes this by connecting to the iOS device through usbmuxd. When the iTunes application is installed on a computer, a utility called usbmuxd (USB Multiplexing Daemon) is installed along with it. usbmuxd is a socket daemon that is started on Mac OSX by launchd (see /System/Library/LaunchDaemons/ It creates a listening UNIX Domain Socket at /var/run/usbmuxd. On Windows the service that hosts this program is named “Apple Mobile Device Service,” and can be seen in services.msc.

Can usbmuxd Be Leveraged By Third Party Apps?

usbmuxd is a socket daemon that listens for iOS device connections to a computer through its USB ports. When the usbmuxd detects an iOS device running in normal mode (as opposed to recovery mode) it will connect to it and then start relaying requests that it receives via /var/run/usbmuxd. This is the only way to connect directly to an iOS mobile device through a USB connection. This means if you want to create a direct line of  communication through USB between a desktop application and a mobile application, that connection must be made through usbmuxd. In order to establish this socket connection through usbmuxd some code needs to be implemented in both the desktop app and the mobile app. The sample code below was written by Carlos Rodriguez in his blog article “Communicating with your iOS app over USB (C# and/or Xamarin).”

How To Create a Connection Using usbmuxd

First the NuGet package iMobileDevice.Net needs to be added to the desktop application project. Here is some sample code using that package to listen for a usbmux “AddDevice” event:

Below, the Connect method gets a “DeviceHandle” reference using the UDID of the connected device. Once it gets that handle, it calls the “ReceiveDataFromDevice” method:

And finally, the below line sends data to the iOS device.

The iOS application would have to implement some code like the following in order to ‘listen’ for an incoming connection on port 5050 (an arbitrarily chosen number that matches the port number in the desktop app code).

Once the above code has been executed a connection that resembles something like a TCP network connection will be established between the MCC Utilities desktop app and the Communication Component inside the app on the iOS mobile device.


It is possible to create a direct connection between an iOS mobile application and a desktop application through USB by leveraging the usbmuxd socket daemon. Data can then be communicated back and forth through this connection in order to accomplish the prescribed data sync between the two applications. This connection will have been established through the usbmuxd socket daemon. This solution can be used to transfer data between iOS devices in a DIL environment with the desktop app as the intermediary.

Leave a Reply