Updated: December 20, 2024
Recently, two things happened. A friend of my gave me his old iPhone, so now I have it available for all sorts of testing. I wrote an article on how to copy local music, sans any cloud nonsense, to the iPhone, using VLC. And then, I wrote a second tutorial, on how to accomplish this with KDE Connect. Three things. Three.
Nobody expects Dedoimedo to quote Monty Python, ha. But now, let's expand on the endeavors above. Namely, my not-cloud music is now on the iPhone, and it plays well. However, it does not show in Apple Music. For some reason, this app does not reflect my locally sourced collection of songs, regardless of where they reside on the device. I thought, well, perchance the iTunes program can help. Only it's not available for Linux. Let's see if we can work around this problem.
Install iTunes in Linux
This guide will have two distinct, separate parts. One, how to install the Windows executable in Linux, and make it run reasonably well. Two, how to sync local content onto the iPhone using iTunes - or rather, how to attempt to do that and fail. But I'm getting ahead of myself. Let's proceed sequentially.
To install iTunes, you will need 1) a Linux machine with WINE configured 2) the iTunes installer. For the former, I've written tons of articles on the subject, so any one of my related tutorials will do. For the latter, you need the iTunes installer (64-bit), but not the latest version. If you go for 12.13 (latest at the time of writing), the program's UI will render black, and it won't be usable. This applies to both 32-bit and 64-bit versions - and the 32-bit versions needs still a few more tweaks to get going. We need iTunes 12.7.
Here is the link to the older version - I've deliberately broken the URL, because it links directly to the installer executable. Please exercise every necessary precaution when handling installer files, potentially outdated software, and all that.
https://secure-appldnld.apple.com/ \
itunes12/091-45357-20180123-72201840-FFEA-11E7-92F9-85B67CCC33A9/ \
iTunes64Setup.exe
You will need to remove the spaces and backslash characters.
Once you've downloaded the file, simply run:
wine iTunes64Setup.exe
Follow the instructions. I would recommend you disable any file association (default player), automatic updates, and ignore the autorun prompt. Once the installation completes, uncheck the box that says: Open iTunes after the installer exits. We want to start the program ourselves.
Run the program, and sign in. For me, this worked without any problems. I got the notification on the phone for a 6-digit one-time code, and everything was hunky dory. I was then able to add local MP3 files to my iTunes library. No problems.
The first login attempt timed out, the second right thereafter worked just fine.
Possible installation and runtime issues
Before we move onto the library syncing step, let me briefly mention a few snags or issues that you may encounter when testing this program and/or trying to install it:
- If you run a 64-bit system with a 64-bit version of WINE, iTunes will complain if you try to set up a 32-bit version. If you do want to do that, you will need to create a separate prefix with WINEARCH=win32.
- If you install a 32-bit version, it will crash. You will need to launch the WINE configuration utility (winecfg), in the right 32-bit prefix, e.g.: WINEPREFIX=/home/roger/.wine32 winecfg, and under the Libraries tab, add the following DLL override: msvcp140.dll.
Ignore the gdiplus entry ...
- If you have already tried to install a newer version of iTunes and then "downgraded", it won't launch. It will complain that the "iTunes Library.itl" file cannot be read, as it was created by a newer version of the program. The solution is to delete the above-named file under your home directory, Music/iTunes.
Connect iPhone, sync (and fail)
This step will not work under Linux, with iTunes running under WINE. Or rather, let me be clearer, at the time of writing, I wasn't able to get this working correctly. Now, I will show you how you can pair your device on the command line (in essence, similar to what KDE Connect does, as outlined in the tutorial linked at the beginning of this article), and while this is handy and useful, it will not help us. I want to mention the procedure here, so you have a full understanding of what can and cannot be done.
TL;DR: Bottom line, the iPhone will not be available under WINE-run iTunes, for a variety of technical reasons. This means, you can run the program, enjoy it as a standalone media player, but you won't be able to make much progress on the sync side.
Now, the instructions. Open a command-line window. The instructions below show all the different problems you may encounter along the way. This will help you work around them easily. All of the required packages are available in Ubuntu-based distribution archives. My test box was a Kubuntu 22.04. To wit:
- Connect your iPhone, trust your computer, keep the iPhone screen unlocked.
- Check the usbmuxd service is active and running:
systemctl status usbmuxd.service
- usbmuxd.service - Socket daemon for the usbmux protocol used by Apple devices
Loaded: loaded (/lib/systemd/system/usbmuxd.service; static)
Active: active (running) since Thu 2024-11-28 12:54:28; 5s ago
Docs: man:usbmuxd(8)
Main PID: 245626 (usbmuxd)
Tasks: 4 (limit: 37995)
Memory: 1.8M
CPU: 253ms
CGroup: /system.slice/usbmuxd.service
└─245626
/usr/sbin/usbmuxd --user usbmux --systemd
Pair the device (notice, this won't work if your system does not have all the packages installed), and you will get a helpful error that tells you what you need to install to get going:
idevicepair pair
Command 'idevicepair' not found, but can be installed with:
sudo apt install libimobiledevice-utils
If you screen is locked, the pairing will fail:
idevicepair pair
ERROR: Could not validate with device [SERIAL] because a passcode is set. Please enter the
passcode on the device and retry.
Unlock the iPhone, try again
idevicepair pair
SUCCESS: Paired with device [SERIAL]
Next, mount the iPhone (with ifuse) to any which mountpoint:
ifuse [mountpoint]
For example:
ifuse /home/roger/iTunes-temp-mount-point
You can now inspect and browse the contents of the mounted filesystem. It's going to be read-only, so you can copy stuff from the iPhone, including photos, which is quite handy, but you cannot delete anything, or copy any fresh files yonder (like say your music). In particular, you will have your songs already available in iTunes under iTunes_Control.
drwxr-xr-x 11 igor igor 352 nov 27 20:45 ./
drwxr-x--- 38 igor igor 4096 nov 28 12:58 ../
drwxr-xr-x 5 igor igor 160 nov 26 19:51 Books/
drwxr-xr-x 4 igor igor 128 nov 26 20:50 DCIM/
drwxr-xr-x 3 igor igor 192 nov 26 19:53 Downloads/
drwxr-xr-x 2 igor igor 64 nov 27 20:45 EnhancedAudioSharedKeys/
drwxr-xr-x 3 igor igor 96 nov 26 20:54 Espresso/
drwxr-xr-x 3 igor igor 96 nov 26 19:51 iTunes_Control/
drwxr-xr-x 3 igor igor 192 nov 27 16:45 MediaAnalysis/
drwxr-xr-x 16 igor igor 640 nov 27 16:42 PhotoData/
drwxr-xr-x 2 igor igor 64 nov 4 08:21 Photos/
Let's go back to iTunes. So, we're logged in, and we can add songs (locally, in the program itself):
I am miffed that two different songs by The B-52's (as the band spells its name) are categorized with slightly different metadata, but I can't be bothered editing the song information right now, although you can do that easily with VLC (check my relevant tutorial in the Media section).
But as you can see, there's no iPhone in the sidebar (even though it's connected and mounted). To see whether this is a WINE problem, and whether song syncing through iTunes actually works, I installed a one-off Windows 11 operating system (yeah, I know, it's useless, avoid if you can) as a virtual machine on this box, and allowed a USB connection pass-through for the iPhone. Indeed, the Windows-installed version of iTunes picked it up, just fine, and even backed up the device.
Then, finally, I was able to sync the local library with the iPhone. It wasn't straightforward, but I did it, and my songs showed up in Apple Music. So, it is doable, but not with iTunes running on a Linux host through WINE. In parallel, I already had all of my music copied and available in VLC, and I was able to do that via two different methods. So unless you really fancy iTunes as a nice media player, it's not the right choice for Linux use, and you won't be able to get the desired results.
Conclusion
All right, this is a somewhat long and convoluted guide, so let's summarize it. Yes, you can install iTunes in Linux, and it will work sort of okay. You need an older version of the program for that. That said, the entire endeavor is rather futile, because you won't be able to really sync your data to the iPhone, as you would or will in Windows, for instance. Not a big problem, as my music is already there. VLC and KDE Connect provideth.
Furthermore, I've also shown you all sorts of problems you may encounter with the iTunes installation. On top of that, you also have the set of instructions to connect, pair and mount the iPhone on the command line, and this gives you good, nice data management flexibility. Not perfect though, and you're better off using KDE Connect. Easier, too. Once again, a built-in Linux tool, part of the Plasma desktop environment, provideth. You really don't need to go down the tricky, proprietary route, especially since it won't give you the desired results.
And thus, it's time to conclude this funny article. I have shown you how to do something, but it's the whole could-should quote from Jurassic Park. There is really no practical value using iTunes in Linux, and who knows, you might even be in breach of license terms here or there. You can enjoy music and video using VLC in iOS, fully, beautifully, and that's about as good as it gets, no real compromise. Apple solutions are best enjoyed within the confines of their design and intended ecosystems, for better or worse. Stay cool.
Cheers.