4

I current use libimobiledevice to work around Mac and iPhone. libusbmuxd is very helpful to get device (iPhone/iPad) information when connects to Mac app through USB.

I want more, I want to read/write data (a file like document, image, video, ...) from Mac to iPhone and vice versa but I can't get any document or tutorial on the Internet guiding how to do it.

Can anyone help me

Scofield Tran
  • 828
  • 1
  • 18
  • 30

2 Answers2

3

If you want to transmit data between OSX and iOS via usbmuxd it is basically a two step process:

  1. Start a socket server on an arbitrary port on iOS or tvOS
  2. Open a socket connection to the usbmuxd server on OSX at /var/run/usbmuxd.

After you have done that you will receive some control messages from the usbmuxd server on OSX including events for device attach and detach. Each device that has been attached to the usbmuxd server has a unique device id. This device id in combination with the port of the socket server can be used to bind the socket connection to the socket server.

If you want to save yourself the trouble of implementing this procedure from scratch you can have a look at the following frameworks. They both provide a high level API in Objective-C.

https://github.com/rsms/peertalk

https://github.com/jensmeder/DarkLightning

Jens Meder
  • 4,237
  • 1
  • 25
  • 25
2

this is actually quite easy. Have a further look at https://github.com/libimobiledevice

Especially look at the iFuse example.

libusbmuxd is a library to use the usbmuxd, which tunnels any socket connections on the iOS device over USB to a local socket.

On every iOS device you can find an open socket on port 62078. This is the so-called lockdownd, which is used for many things. With lockdownd you can start the AFC service (Apple File Conduit), which is a network filesystem service.

libimobiledevice does all of this for you. (Look at libimobiledevice/afc.h, here are all filesystem related functions like reading a file, retrieving a directory, etc.)

Things you have to do:

  • call lockdown_client_new_with_handshake(..)

  • call lockdownd_start_service(..) with the "com.apple.afc" service

  • if your device is jailbroken, you get full filesystem access with the "com.apple.afc2" service, but otherwise the standard service should do well.

By the way: The lockdownd connection works only if your device is unlocked.

Ciao, Arno

akw
  • 2,090
  • 1
  • 15
  • 21