Create a gist now

Instantly share code, notes, and snippets.

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 automake libtool pkg-config libplist-dev libplist++-dev python-dev libssl-dev libusb-1.0-0-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. libimobiledevice
  3. usbmuxd
  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
@samrocketman
Owner

Photos are located in DCIM folder.

@joemclo
joemclo commented Nov 11, 2016

Thanks,
This really helped me out.

Just a note, I got an error when I tried to build usbmuxd before libimobiledevice.
I swapped the order and it worked great

@darka91
darka91 commented Nov 29, 2016

Thanks

@samrocketman
Owner
samrocketman commented Dec 27, 2016 edited

@joemclo I'll try my instructions again in a fresh Vagrant VM and update them. Thanks for letting me know.

edit: fixed

@murshid1988
murshid1988 commented Dec 29, 2016 edited

Holy Moly. Thanks. This works.

@luckrk
luckrk commented Jan 1, 2017

Thank you for that!

@eura665
eura665 commented Jan 2, 2017

Thank you Sam!!!!!!!
This works with LinuxMint18.1 and iOS10.2 ;-) ;-) Now I access my phone via usb cabel

@Sadi58
Sadi58 commented Jan 8, 2017

Thanks a lot Sam!

And here's a tiny & handy script I wrote and added to Unity Launcher > Unity Tweak Tool menu as iOS Device info, iOS Device mount, and iOS Device unmount:

#!/bin/bash

info()
{
Device=$(lsusb | grep Apple | awk -F "Inc. " '{print $2}')
VendorID=$(lsusb | grep Apple | awk -F " " '{print $6}' | awk -F ":" '{print $1}')
ProductID=$(lsusb | grep Apple | awk -F " " '{print $6}' | awk -F ":" '{print $2}')
zenity --class=iOS --info --width 200 --height 200 --title="iOS Device Connected" --text="\n \
<big><b>$Device</b></big>\n \
<b>• Vendor ID:</b> $VendorID\n \
<b>• Product ID:</b> $ProductID"
}

mount()
{
cd ~/
mkdir -p 'iOS Device'
ifuse 'iOS Device'
nautilus --no-desktop --new-window 'iOS Device'
}

unmount()
{
cd ~/
fusermount -u 'iOS Device'
rm -R 'iOS Device'
}

##############

if [ $# -eq 0 ]
then
	echo "You should specify a function as parameter; e.g. view_device_info"
	exit 1
else
	for func do
		[ "$(type -t -- "$func")" = function ] && "$func"
	done
fi

exit 0

Later I might try to include frequently used iOS devices in udev rules so that they are mounted and displayed by nautilus automatically when they are plugged in, etc. That's why I have "device info" included as well...

@cedriczg
cedriczg commented Jan 9, 2017 edited

I was able to perform all the steps. However I am getting following error when executing ifuse:

$ idevicepair pair
SUCCESS: Paired with device f874f69d8adcef0a2dc207e565e2085cab45da02
$ ifuse ~/usr/mnt/
Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

How can I sort out this issue? Thanks in advance.

N.B.: I had also to compile libplist in order to get libplist.so.3 under my /usr/local/lib

@rocmail520

To my knowledge, remove libimobiledevice6 and then follow the instructions from here.

code:
sudo apt-get remove libimobiledevice6

@rocmail520

This enables to view/copy all the folders but how to transfer music to/from,,, lets say using banshee?

@pajraj
pajraj commented Jan 14, 2017

Please help me, I am new to Linux.
The .bashrc settings: I have to insert these into my .bashrc? I searched and I have about 6 .bashrc files in the system, which one should include these?

Thank you

@danielrmeyer

I was completely screwed after updating my iphone to the current version 10.2 (14C92). I followed your steps and I am able to get my photos and data from my iphone. I really don't know how to express my gratitude fully, but thank you for this terrific write-up.

@drchriscole

Trying this on 14.04 without much luck. Firstly also needed https://github.com/libimobiledevice/libplist as installed version was too old for libusbmuxd. All compilations went smoothly, but I still get this:

$: ~/usr/src/ifuse> ifuse ~/usr/mnt
Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

Anyone managed to get this working on 14.04?

@jrthorne

Thanks heaps. this really helped me out. Damn iPhone automatic updates!

@samrocketman
Owner
samrocketman commented Jan 22, 2017 edited

@drchriscole I can try to get this working with Ubuntu 14.04 tomorrow.

@samrocketman
Owner

I tried and was not able to get it to work with Ubuntu 14.04. I might be able to get it to work if I spent a few more hours on it. But I don't want to spend several hours on it.

@martinmolema

You rock! It works! Normally I always have problems compiling from source, but your instructions work first time right!

@andreaferretti

That was great!

@joemac42

I'm also pretty new with this and I would like some further explanation on how to modify .bashrc. Do I just copy the code example verbatim and paste into the .bashrc in my home directory or is it located somewhere else? Also, do I need to uninstall libimobiledevice before doing any of this? Does that then mean that once the package maintainer's version catches up with iOS 10.2, I should undo this and switch back?

@drchriscole

@samrocketman oh well. Thanks for trying nonetheless.

@kflavin
kflavin commented Feb 8, 2017

Worked great, thanks!

@janclaussen

For me nothing really works. I tried installing the files to the home folder and to the root /usr/src. In both cases no changes of the behaviour. I get the same error message:

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.

Plus this output:
type -p ifuse
/usr/local/bin/ifuse

I tried executing the commands as root, as well as the user with sudo commands when needed.

What am I doing wrong? Can't you create a repository for this?

@benwinding

After executing the following command:

$ ./autogen.sh --prefix="$HOME/usr"

I get the following error:

bash: ./autogen.sh: /bin/sh^M: bad interpreter: No such file or directory

Any sugguestions?

@robertoandrade

Trying to do this on Ubuntu 14.04 with iOS 10.2 and all seems to works but idevicepair pair yields: No device found, is it plugged in?.

When lsusb it shows the phone just fine on the list. Anybody had success with this kind of setup?

@stuhli
stuhli commented Feb 20, 2017

Great work! You made my day!

After weeks of not getting my pictures backed up I'm now able to do so.

Thanks a lot!

@bigbroseur

Works fine on Debian GNU/Linux 8 - 64 bits with iOS 12.2.1
Thanks

@acyuta108

@robertoandrade when you pasted the commands to the terminal, it seems like your clipboard inserted and ^M which is a newline character. Try typing it out or open a new terminal window to make sure your current terminal does not have some strange stuff in it.

@centzon400
centzon400 commented Mar 6, 2017 edited

Sam, you rock it, man!

Host: minty Kernel: 4.4.0-53-generic x86_64 (64 bit)
Desktop: Cinnamon 3.2.7 Distro: Linux Mint 18.1 Serena
iOS: 10.2.1 (14D27)

@gangesh
gangesh commented Mar 6, 2017

Works as stated!

Now I want to transfer files from computer to iphone and view there for sharing etc.
Possible?

@mjensen007
mjensen007 commented Mar 16, 2017 edited

UPDATE:
I followed all instructions but still got the error "GnuTLS error: Error in the pull function."

I was finally able to get it working by searching my HD for "libimobile*" and deleting every instance of this file/folder from my HD. Then I deleted libusbmuxd, libimobiledevice, usbmuxd, ifuse folders from my ~/usr/src/ director, ran through sam's detailed steps again, and it worked!

@degenaro

Excellent! Sam thanks a bunch for this post - helped me with Ubuntu 16.04 and iPhone 6 with IOS 10.2.1.

@mtwsec
mtwsec commented Mar 20, 2017

Thanks so much for the detailed instuctions, Sam!
Worked perfectly for me - Ubuntu 16.04, iphone 5c, IOS 10.1.1.

@obrut2
obrut2 commented Mar 20, 2017

Perhaps I messed something up, as I executed the instructions multiple times, but I am running into a problem.

I can pair the device, but ifuse returns:
Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

I am on Ubuntu 14.04, and iPhone 5C with iOS 10.2.1. I noticed that others on 14.04 got the same error. So perhaps there is a library that needs upgrading. Was anyone on 14.04 successful at getting these instructions to work?

Thanks!

@obrut2
obrut2 commented Mar 20, 2017

Now I can confirm that these instructions work on Ubuntu 16.04, but not 14.04. If anyone knows of the missing piece for 14.04, please post. Thanks!

@sooheib
sooheib commented Mar 20, 2017

After executing the following command:

./autogen.sh --prefix="$HOME/usr"

I get the following error:

configure: error: Package requirements (libplist >= 1.11) were not met:

Requested 'libplist >= 1.11' but version of libplist is 1.10

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libplist_CFLAGS
and libplist_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Any sugguestions?

@starkraving

Thanks, I was finally able to copy my iPhone's photos onto my Ubuntu 16.04 machine. Couple of things:
1 - Trying to unmount ~/usr/mnt gives the error "fusermount: old style mounting not supported"
2 - Can this be used to regain access to the phone's "Documents" folder as well? That's gone missing since the iOS 10 upgrade as well.

@Lergill
Lergill commented Mar 24, 2017

New to this, on Ubuntu 16.04 Gnome3, When you say $HOME you really mean your HOME file. search Internet how to add to a bash file Found Ubuntu page to use echo at beginning and >> ~/.bashrc at the end of the lines, is this correct or should I remove.
Idevicepair pair I get success but Ifuse : Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

@ricciolino

Hi, in my ubuntu 16.10 not work!
after installing libusbmuxd, qhen i try to install libimobiledevice i got this error:

checking for libusbmuxd... no
configure: error: Package requirements (libusbmuxd >= 1.0.9) were not met:

No package 'libusbmuxd' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libusbmuxd_CFLAGS
and libusbmuxd_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

What can i do to fix?
Thanks

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