Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Last active July 3, 2024 07:05
Show Gist options
  • Save samrocketman/70dff6ebb18004fc37dc5e33c259a0fc to your computer and use it in GitHub Desktop.
Save samrocketman/70dff6ebb18004fc37dc5e33c259a0fc 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.

Audience

Who is this guide intended for?

Compiling software is what I would consider an advanced Linux skill. If you're not interested in tinkering with your operating system then this guide may not be for you. There's a lot of concepts I don't explain or gloss over with brevity to keep these instructions brief (compared to explaining everything).

While I did my best to think of beginners when creating this guide; this guide is not for the faint of heart. If you've not compiled software before then I recommend you practicing inside of VirtualBox before attempting this on your real system. Follow this guide at your own risk because I can't make any guarantees based on unknown individual skill level.

Support

This solution works for (posted via comments):

  • Archlinux
  • Debian GNU/Linux 8 - 64 bits
  • Debian GNU/Linux 9
  • Kubuntu 18.04
  • Linux Mint 18
  • Linux Mint 18.1
  • Linux Mint 18.2
  • Linux Mint 18.3
  • Linux Mint 19.1 Cinnamon
  • openSUSE Leap 42.3
  • Raspbian GNU/Linux 9.4 (stretch)
  • Ubuntu 16.04
  • Ubuntu 17.04
  • XUbuntu 16.04

This solution does not work for the following:

  • Ubuntu 14.04

On Ubuntu 16.04, I have personally used this method to connect to iOS 10. Other users report connecting (via comments):

  • iOS 10
  • iOS 10.1
  • iOS 10.2
  • iOS 10.3.1
  • iOS 10.3.3
  • iOS 11.2.2
  • iOS 11.3.1
  • iOS 11.4
  • iOS 11.4.1
  • iOS 12.0
  • iOS 12.0.1 (16A404)
  • iOS 12.1.4

Hardware: I have personally successfully used this method on an iPhone 5S. The following is a list of hardware successes from other users (via comments below).

  • iPhone 5C
  • iPhone 5S
  • iPhone 6
  • iPhone 6 Plus
  • iPhone 7
  • iPhone 8
  • iPhone 8 Plus
  • iPhone SE
  • iPod Touch 6th Generation

If you get this working on a flavor that I don't list, then please post a comment and I will update this support section.

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

Building on other platforms and OSes (reported in user comments)

Jump to Clone and Build.

Building on Ubuntu 16.04

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 and Build

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. libplist (not required on Ubuntu 16.04)
  2. libusbmuxd
  3. libimobiledevice
  4. usbmuxd
  5. ifuse

Note: (Optional) If you have a system package installed which is in the above list, then I recommend uninstalling it. However, if you can't uninstall it, then no big deal. It is mostly a precautionary measure. As long as you set the bash environment variables properly, then your compiled version should not reference your system packages. Uninstalling any system packages is by no means required.

Note 2: Removing usbmuxd was required on Debian Jessie 8.10 mentioned in comments.

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

Browsing Photos

The mounted iPhone has an empty Photos folder. Strangely, this has no photos. Instead, look in the DCIM folder for photos.

I have only copied photos off of my iPhone as a backup. I have not tried copying photos to my iPhone.

Browsing Music

It is a known issue music sync no longer works in later versions of iOS with libimobiledevice. Since Apple changed some things (outlined in linked issues), music sync hasn't worked since as early as iOS 6 and still doesn't work.

@justinpearson
Copy link

justinpearson commented Jun 28, 2018

Excellent, thank you so much!!
Jun 28, 2018
Raspbian GNU/Linux 9.4 (stretch)
iPhone 5s, iOS 11.4

Note: sudo service usbmuxd status showed error "Dropping privileges failed, check if user 'usbmux' exists!", so I should've done sudo apt-get install usbmuxd to create the usbmux user, then sudo apt-get remove libimobiledevice6 ifuse usbmuxd to remove the built-in packages (but leaving the usbmux user) before starting your directions.

@oldpink
Copy link

oldpink commented Jun 29, 2018

Just a heads up for anyone with a newer iPod Touch or (at least I presume) anyone with either an iPad or iPhone running iOS 11.4, but (when doing "ideviceinfo" or "ifuse /mnt/ipod" I was repeatedly getting the dreaded:

Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

I was able to get my iPod Touch 6th Generation to pair with "idevicepair pair," but it would not mount.
I'm not a Ubuntu user (Slackware 14.2), so I had built the five essential packages from latest source on the libimobiledevice Github (http://www.github.com/libimobiledevice), with the following versions of each package:
libplist = 2.0.0
libimobiledevice = 1.2.0
libusbmuxd = 1.0.10
usbmuxd = 1.1.0
ifuse = 1.1.3
I finally managed to get that last step working by downloading libimobiledevice-1.2.1 from pkgs.org (ALT Linux Sisyphus, FWIW), then building and installing that.
Now, I'm off to see how to get Gtkpod to fully recognize it and allow moving music onto it.
Just thought my explanation might be helpful for those who still build their sources by hand.

@oldpink
Copy link

oldpink commented Jul 3, 2018

For some reason, it's really tough to find, but after a bit more poking around, the best I could determine is that all current revisions of iOS, I believe from version 6 onward, will no longer sync music via the libplist/libimobiledevice/libusbmuxd/usbmuxd/libgpod method.
Does anyone know if there is any progress being made to get around yet another of the roadblocks being put up by the ghost of Steve Jobs on this front?

@ms502040
Copy link

ms502040 commented Jul 11, 2018

Thanks, working on openSuse Leap 42.3
iOS 11.4.1
only need change lib dir to lib64 in PKG_CONFIG_PATH and LD_LIBRARY_PATH:

[ ! -d "$HOME/usr/src" ] && mkdir -p "$HOME/usr/src"
export PKG_CONFIG_PATH="${HOME}/usr/lib64/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/lib64:${LD_LIBRARY_PATH}"

@beniSu
Copy link

beniSu commented Aug 12, 2018

Thank you.
worked step by step through.

@morkeltry
Copy link

Nice!
It just works.

I wish it was higher up in my Google search!

@raf-sh
Copy link

raf-sh commented Aug 16, 2018

if you got this message on Ubuntu
"No package 'libusbmuxd' found"
while https://gist.github.com/samrocketman/70dff6ebb18004fc37dc5e33c259a0fc#build-libimobiledevice
install libusbmuxd-dev
sudo apt-get install libusbmuxd-dev

@darkzone
Copy link

darkzone commented Sep 22, 2018

working on Debian 9 with iOS 12.0 (iPhone 7)

@morkeltry
Copy link

Nnnggg! It worked once (my comment above) on my Ubuntu 16.04.4 with kernel 4.16.13 and now it no longer does :(
After ifuse ~/usr/mnt I get:

Failed to connect to lockdownd service on the device.
Try again. If it still fails try rebooting your device.

I guess Apple must have crept into the phone in the night and added more obstacles :(

@michel-briand
Copy link

Debian stable: ifuse 1.1.2-0.1+b5

ifuse fails with the same error message:

Try again. If it still fails try rebooting your device.

ipairdevice pair works.

After some browsing, I found Sam Rocketman's article:
https://gist.github.com/samrocketman/70dff6ebb18004fc37dc5e33c259a0fc

I had the idea to upgrade libimobiledevice6 from stable to stretch-backports. And it worked!

@MoralCode
Copy link

I can confirm this method works on Kubuntu 18.04 with an iPhone 8 running iOS 12.0.1 (16A404)

@dirtygardner
Copy link

dirtygardner commented Nov 6, 2018

Error message when trying to mount iPhone-6-MG642LLA with ifuse:
Failed to connect to lockdownd service on the device.

After Erase All Content and Settings, successfully mounted and accessed iPhone-6-MG642LLA.

Instructions from https://wiki.debian.org/iPhone :

uname -a: Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux
lsb_release -a: Debian GNU/Linux 9.5 (stretch)

Tested on (iPhone-#-MODEL):
iPhone-5c-MGFG2LLA
iPhone-6-MG642LLA

Instructions (see https://www.dedoimedo.com/computers/linux-iphone-6s-ios-11.html)
[TERMINAL] apt install ideviceinstaller python-imobiledevice libimobiledevice-utils libimobiledevice6 libplist3 python-plist ifuse usbmuxd libusbmuxd-tools
[TERMINAL] usbmuxd -f -v
[DEVICE] connect to TERMINAL via USB cable
[TERMINAL] open new shell window (may not be necessary)
[TERMINAL] idevicepair pair
[DEVICE] Trust This Computer? Tap Trust
[TERMINAL] idevicepair pair
[TERMINAL] mkdir /media/iPhone
[TERMINAL] ifuse /media/iPhone

@seanvaleo
Copy link

using stretch-backports libimobiledevice6 and libimobiledevice-utils works for me too. before this i had a lockdownd error

@designzwang
Copy link

Wow - triple thumbs up, thank you!! This saved both my ass and a lot of time ...

I used:

  • Debian Stretch 9.8 ( Guest System running on a Virtualbox virtual machine!)
  • Iphone 6 ( MG4F2ZD/A) with IOS 12.1.4
  • I did not build plist/libplist, but made sure that I had the debian packages installed before I started the process
    ( libplist-dev and libplist3 )

So let me confirm that these instructions worked without any modification/problem if followed correctly (regarding the setup of the paths).

After mounting the phone with ifuse, I could successfully access both the photos (DCIM) and MP3s (in iTunesControl/Music ). Note that I did not try to write anything onto the phone, i just grabbed the stuff for backing it up/transferring to my new phone.
Since Virtualbox was running without the USB 2.0 addon, I was limited to USB 1.1 (slow ...) but I could copy the files successfully.

I would suggest to add $HOME/usr/sbin to the path also, because thats where usbmuxd ends up.

Now I wonder how to turn the Itunes folder tree ( creates path/file names like /F00/1234.mp3 and so on) into something useful ....
But anyway, thats a different problem. In the first place, I am grateful that I got my stuff downloaded. Shame on Apple to make that so difficult, and credits to you!
Regards
Ulrich

@ingenerd
Copy link

Thanks alot. Works for iPhone SE with iOS 12.1.4 and Debian 9.8 (stretch).

@rdana-vermont
Copy link

Fantastic! Thank you so much for this. Just verified that this works perfectly on Linux Mint 19.1 Cinnamon.

@samrocketman
Copy link
Author

samrocketman commented Apr 4, 2019

Thanks for reporting back, all. Article updated.

@babacarcissedia
Copy link

Dude you are just awesome! it saved me a lot of time digging and testing. thanks!!

@sunbearc22
Copy link

sunbearc22 commented Apr 10, 2019

@samrocketman Thank you for sharing. I was able to implement your instructions and ifuse worked as you said. Really appreciate you sharing this solution.

I like to share with you a new discovery. Have you come across the Ubuntu LTS Enablement Stacks? Essentially, it provides newer kernel and X support for existing Ubuntu LTS releases. I learnt about it recently, and have installed it. For a Ubuntu 16.04.1 system that had previously used the 4.10.0-42-generic linux kernel, it now can operate with a 4.15.0-47-generic linux kernel. The good news is that purely by using the newer linux kernel made available by Ubuntu, w/o even implementing the latest version of the locally compiled libusbmuxd, libimobiledevice, usbmuxd and ifuse packages, I discovered that Nautilus and Shotwell both can now access and import photos and videos from a iPhone 6 that uses iOS 12.2. You might want to have a go at installing Ubuntu LTS Enablement Stacks.

Note: Presently, this solution allows Shotwell to import pictures and movies from the iPhone. However, I have encountered that the movies files may not be imported in the correct folder and some photos being relabelled (e.g. from IMG_0147.JPG to IMG_0147_1.JPG). After importing, don't use Shotwell to delete the photos and videos from the iPhone yet; do it via iPhone for now as a precaution. Situation seems to be evolving for the better.

@gservat
Copy link

gservat commented Apr 17, 2019

Thanks very much for your guide!

I'm using Ubuntu 18.10 (kernel 5.0.5 FWIW) and an iPad 3 and it worked great. Couple of notes:

  • If you want to manage the apps on your device, try doing a git clone https://github.com/libimobiledevice/ideviceinstaller.git and the usual ./autogen.sh --prefix="$HOME/usr" && make && make install dance. You'll need to have libzip-dev installed. You can now, for example, list installed apps with ideviceinstaller -l
  • If you're trying to upload videos into your iOS device, I'm using VLC so I had to do: ifuse --documents org.videolan.vlc-ios /path/to/mnt.

@samrocketman
Copy link
Author

Wow, I’ll have to try these. They’re really awesome tips @sunbearc22 @gservat

@bengtan
Copy link

bengtan commented Apr 22, 2019

Awesome!

Works for me at 20190422 on Xenial 16.04 with iPhone 6 (11.2.1), although I only tested (and care about) retreiving photos from DCIM.

Note that I only built and installed libusbmuxd, libimobiledevice and ifuse.

I was using libplist and usbmuxd from https://launchpad.net/~martin-salbaba/+archive/ubuntu/ppa+libimobiledevice and they seem to interoperate fine.

@bengtan
Copy link

bengtan commented Apr 22, 2019

... and just upgraded the iPhone 6 to iOS 12.2 and all seems to be working fine.

@007fred50
Copy link

i can get it to work on iPhone 6 but not iPhone 7.
can some one help me how i con get it to work on iPhone 7 and others device.

i'm workin in ubuntu 16.04.

@dublinx333
Copy link

There are many citations on the internet saying Linux Mint 18 or later works fine out of the box (see Example below).
So I'd like to know if the fix/solution elaborated here is really necessary for those with Mint 18. (Fyi, I have Linux Mint 19.2. and would really like to know if it works with iOS out of the box)
If the solution is NOT necessary can someone (the author) clearly restate for which iOS/Linux distro. the solution is necessary?
Example citation: https://askubuntu.com/questions/928750/how-do-i-access-ios-camera-pictures-on-ubuntu

thx

@samrocketman
Copy link
Author

samrocketman commented Nov 10, 2019

@dublinx333 I don't use Mint myself so can't comment on its out of the box support. However, consider the following:

  • I believe Mint has a live distro from which you can try it out without installing. I recommend trying it out and seeing if out of the box support exists.
  • If it doesn't work out of the box, others have reported using the latest libimobiledevice sources work. This guide documents hints and workarounds for someone who wants to compile it themselves; whatever their distribution.

I myself only have an iPhone 6 and tend to keep it up to date with the latest available iOS.

@samrocketman
Copy link
Author

Also worth noting on Pop OS 18.04 and Ubuntu 18.04 I didn't need to compile anything for out of the box support. I imagine any mint version based on this would also have out of the box support.

I was able to copy home videos onto my VLC app on iPad and copy off files and pictures from my iPhone.

@20k-ultra
Copy link

20k-ultra commented Feb 22, 2020

I can confirm that by following these instructions I was able to fix my issues connecting to my iPhone. Prior to this I installed the same tools from apt and would get the following response with idevicepair validate command: idevicepair unhandled error code 3

Only tweaks required were to use sudo install for some make installs when I got permission issues as well as install some dev versions of libraries when building some of the libraries.

Debian Stretch 9.12
iPhone X
iOS 13.3

Thank you!

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