Richard Bernecker

Random Solutions to Random Problems

Compiling libimobiledevice on Fedora 38

If you’re looking to backup your iPhone to Linux, you’ll need to look at libimobiledevice to replicate iTunes backups that are available on Windows or MacOS. Fedora’s official repository contains a packaged version of libimobiledevice, but this version is too old to speak to newer iOS versions like iOS 16 or 17.

To work with the latest iOS versions, you’ll need to build, at a minimum and in order, the following packages from the official GitHub:

-libplist

-libimobiledevice-glue

-libusbmuxd

-libimobiledevice

It’s worth noting that usbmuxd is a key dependency in this application stack, but I’ve found that it’s easier and more reliable to install the version hosted in Fedora’s official repository rather than building from scratch.

The commands needed to compile libimobiledevice are listed below. You’ll want to pass in the PKG_CONFIG_PATH environment variable when calling the autogen scrip for most of these builds as they will require our self-compiled version of libplist. The ldconfig commands are run after each package install to ensure that the libraries they produce are available for each subsequent package that may need them.

sudo dnf install git autoconf automake pkg-config doxygen cython make automake gcc gcc-c++ glibc kernel-devel libtool openssl-devel usbmuxd

git clone https://github.com/libimobiledevice/libplist.git
git clone https://github.com/libimobiledevice/libusbmuxd.git
git clone https://github.com/libimobiledevice/libimobiledevice.git
git clone https://github.com/libimobiledevice/libimobiledevice-glue.git

#Packages must be built in order to meet required dependencies 

cd libplist

./autogen.sh
make
sudo make install
sudo ldconfig

cd ../libimobiledevice-glue
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install
sudo ldconfig

cd ../libusbmuxd

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install
sudo ldconfig

cd ../libimobiledevice

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install

Assuming you installed usbmuxd via Fedora’s official repository, you may find that the service is in a failed state. It may throw one or both of the below errors. You’ll want to modify the systemd service file as seen below in that case and ensure permissions are correctly set on the lockfile directory and process file. If you modify the service file, reload and restart the daemon as shown below.

usbmuxd errors in systemd

[03:52:02.221][0] Dropping privileges failed, check if user 'usbmux' exists!

[05:04:49.329][0] Could not open lockfile

Modified usbmuxd service file

Located at: /usr/lib/systemd/system/usbmuxd.service

[Unit]
Description=Socket daemon for the usbmux protocol used by Apple devices
Documentation=man:usbmuxd(8)

[Service]
ExecStart=/usr/sbin/usbmuxd --user usbmuxd --systemd
PIDFile=/run/usbmuxd.pid

Reloading and restarting the usbmuxd daemon (if modifying the service file)

sudo systemctl daemon-reload
sudo systemctl restart usbmuxd.service

Working example permissions

drwxrwsr-x. 1 usbmuxd usbmuxd 112 Nov 24 06:14 /var/lib/lockdown

srw-rw-rw-. 1 root root 0 Nov 25 04:57 /var/run/usbmuxd

And That’s it! You should now be able to plug your iPhone into your Fedora machine and use any of the utilities bundled directly with libimobiledevice. There are other packages on the official GitHub if you need a function that’s not included here. The build process for those should be similar to the above.