Fixing a Corrupt Apple Music Library on macOS (Without Losing Your Data)

Apple Music on my Mac recently started hanging on “Saving Library,” forcing me to Force Quit the app. At the same time, play counts from my phone stopped syncing, my Smart Playlists weren’t updating, and nearly every change I made to my music triggered several seconds of the dreaded spinning beachball.
It was pretty clear that my library had become corrupted.


This had happened to me before. The last time, I solved it by deleting my library and re-importing all my music. That restored the songs themselves, but I lost all of my playlists, ratings, and play counts. As someone who cares a lot about metadata, that was painful—and rebuilding everything took a long time.
This time I tried a different approach.


Before deleting the library, I exported it as an XML file. Then I removed the existing library, restarted Apple Music, and imported the XML file. After that, I re-imported my music files.
For the most part, it worked flawlessly.


I had to tweak a couple of Smart Playlists, but all of the metadata—playlists, ratings, and play counts—came back intact, with the exception of the Date Added field.


Considering how much work it saved me, exporting the XML first is definitely the way I’ll handle a corrupted Apple Music library from now on.