Friday, September 2, 2011

Syncing your iPhone with multiple iTunes 10 libraries (updated)

Update (May 27th, 2014): 
Since many people seem to try this with iTunes 11, please be advised: I have not tried this with anything else than iTunes 10. Apple tends to change the internal workings of iTunes, especially between major releases. So don't expect this to work on any other version than 10.

Many people commented it doesn't work on 11 anymore. I couldn't test this since I'm not using this hack anymore nowadays, but I wouldn't be surprised if it is indeed so.



After getting a MacBook Air recently, I wanted to use my iPhone with iTunes on that machine. But when you try to sync an iPhone that has been synced with another iTunes-installation, you get an error and are only given the option to clear the library on your iPhone.

I remembered hacks for older versions of iTunes that let you clone the unique ID of one media library to another iTunes installation. The trick was to read the ID from the "iTunes Music Library.xml" of one iTunes-Installation and apply that to both the "iTunes Music Library.xml" and "iTunes Library.itl" (binary) of another installation. Newer iTunes-Versions (v10.4 at least, not sure when it was introduced) were changed to not make it as easy anymore by adding some sort of checksum to the binary file.

To get to the point: it's still possible, by doing the following steps:

1. On source-machibe: get your ID you want to clone (existing iTunes, with which your iPhone is synced)

  • go to your Home-directory -> Music/iTunes
  • open "iTunes Music Library.xml", the ID is in the <string>-tag after the "Library Peristent ID"-<key>.


2. On target-machine: clone ID to another iTunes installation

  • first, close and exit iTunes if it's still running
  • go to your Home-directory -> Music/iTunes
  • open "iTunes Music Library.xml" and overwrite the ID with the one you got from the other library in step 1
  • delete the file "sentinel". It might be hidden, so make sure you have your system set to show hidden files
  • now we need to "corrupt" the "iTunes Library.itl" file. Do this any way you want, I simply did a echo "junk" > iTunes Library.itl but whatever works for you. Deleting it and recreating a text-file with the same name will probably work as well.


3. have iTunes recreate the library

  • now restart iTunes. It should detect that the library is corrupted and will ask you if you want to have iTunes rebuild it. Say yes.
  • Done! Now you should be able to sync your iPhone with iTunes