Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mmhobi7/1e354ee60dbe40f64efe7e4f98f720d4 to your computer and use it in GitHub Desktop.
Save mmhobi7/1e354ee60dbe40f64efe7e4f98f720d4 to your computer and use it in GitHub Desktop.
On Ubuntu 16.04, since iOS 10 update, libimobiledevice can't connect to my iPhone. This is my attempt to document a fix.

Why this document?

I upgraded my iPhone 5s to iOS 10 and could no longer retrieve photos from it. This was unacceptable for me so I worked at achieving retrieving my photos. This document is my story (on Ubuntu 16.04).

The solution is to compile libimobiledevice and ifuse from source.

Setup environment

Don't forget to set up your environment before building. I typically build and install packages to my local user at $HOME/usr.

sudo apt-get install -y build-essential git

Here's a peek at my .bashrc settings:

[ ! -d "$HOME/usr/src" ] && mkdir -p "$HOME/usr/src"
export PKG_CONFIG_PATH="${HOME}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
export CPATH="${HOME}/usr/include:${CPATH}"

export MANPATH="${HOME}/usr/share/man:${MANPATH}"

export PATH="${HOME}/usr/bin:${PATH}"
export LD_LIBRARY_PATH="${HOME}/usr/lib:${LD_LIBRARY_PATH}"

Notes:

  • Important! PATH and LD_LIBRARY_PATH is important because it is the runtime of libimobiledevice and ifuse to fix mounting iOS 10 devices.
  • MANPATH is only used when looking up man pages so it's optional (I recommend it).
  • PKG_CONFIG_PATH and CPATH is used at compile time to resolve dependencies.

Build libimobiledevice and ifuse from HEAD

Install development packages discovered through trial and error.

sudo apt-get install libbz2-dev python-dev autoconf automake libtool pkg-config libplist-dev libplist++-dev libusb-1.0-0-dev libgcrypt20-dev libgnutls28-dev libgpg-error-dev libfuse-dev

Clone the sources.

cd ~/usr/src
for x in libusbmuxd usbmuxd libimobiledevice ifuse; do git clone https://github.com/libimobiledevice/${x}.git;done

Now build in order (the order matters):

  1. libusbmuxd
  2. usbmuxd
  3. libimobiledevice
  4. ifuse
Build libusbmuxd
cd ~/usr/src/libusbmuxd
./autogen.sh --prefix="$HOME/usr"
make && make install
Build libimobiledevice
cd ~/usr/src/libimobiledevice
./autogen.sh --prefix="$HOME/usr"
make && make install
Build usbmuxd

Unfortunately, sudo make install is required because it needs to write to /lib/udev/rules.d and /lib/systemd/system.

cd ~/usr/src/usbmuxd
./autogen.sh --prefix="$HOME/usr"
make && sudo make install
Build ifuse
cd ~/usr/src/ifuse
./autogen.sh --prefix="$HOME/usr"
make && make install

Connect iPhone

Create a mount point and verify the paths of the tools before executing.

$ mkdir -p ~/usr/mnt

$ type -p ifuse
/home/sam/usr/bin/ifuse

$ type -p idevicepair
/home/sam/usr/bin/idevicepair

Now attempt to mount using ifuse.

$ idevicepair pair
SUCCESS: Paired with device 37b633350ab83dc815a6a97dcd6d327b12c41968

$ ifuse ~/usr/mnt/

$ ls ~/usr/mnt/
AirFair  Books  CloudAssets  DCIM  Downloads  FactoryLogs  iTunes_Control  MediaAnalysis  PhotoData  Photos  PhotoStreamsData  PublicStaging  Purchases  Radio  Recordings  Safari  Vibrations

When you're finished. Unmount ~/usr/mnt using fusermount. For example,

fusermount -u ~/usr/mnt
@bsima
Copy link

bsima commented Jan 27, 2017

If this happens:

$ ifuse : ifuse ~/mnt
GnuTLS error: Error in the pull function.
Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

Try doing ldconfig from the command line

@wnarifin
Copy link

Thanks. Worked perfectly on Mint 18.1.

Additionally for the builing libimobiledevice, I had to install 2 additional packages to make it work

sudo apt-get install cython libssl-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment