Cannot load iTunesLibrary on macOS Sequoia 15.1

I use the iTunes Library framework in one of my apps, starting with macOS Sequoia 15.1 i can't create the ITLibrary object anymore with the following error:

Connection to amplibraryd was interrupted. clientName:iTunesLibrary(ITLibraryLoader)

Error connecting to the server via proxy object Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.amp.library.framework" UserInfo={NSDebugDescription=connection to service named com.apple.amp.library.framework}

configure failed: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.amp.library.framework" UserInfo={NSDebugDescription=connection to service named com.apple.amp.library.framework}

I created a new sandboxed macOS app, added the music folder read permission and it reproduced the error:

import SwiftUI
import iTunesLibrary

@main
struct ITLibraryLoaderApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    var body: some View {
        Button("Load ITLibrary") {
            loadLibrary()
        }
    }
    
    func loadLibrary() {
        do {
            let _ = try ITLibrary(apiVersion: "1.0", options: .none)
        }
        catch {
            print(error)
        }
    }
}

I restarted my developer machine and the music app with no luck.

I found a solution to this problem after losing a full day.

Thanks again to Apple for releasing an update that serves no purpose other than making life even harder for us developers. Every time an update is released, I dread installing it because I know very well that many apps will stop working after the update.

I had coded two applications that use iTunesLibrary. They worked perfectly before, but now they don't work anymore, throwing the same error:

Code=4097 "connection to service named com.apple.amp.library.framework".

Based on the documentation, I suspected an issue with sandboxing, entitlements, or binary signing ... but no, that wasn’t the root of the problem.

After trying to mimic some behaviors of the "Music" app, like com.apple.amp.artwork.client, com.apple.amp.devices.client, com.apple.amp.library.client, com.apple.security.files.user-selected.read-only ... and experimenting with various options (some documented, some not), I stumbled upon something incredible that gave me the solution:

I had moved my working folder (including the binary for the new program using iTunesLibrary) to the trash from VSCode. Out of frustration, I executed directly the binary from the ~/.Trash from iTerm2, and bam: the program worked ! No error.

And yet, as far as entitlements in the binary were concerned, I had stripped everything down to the following:

$ swiftc -g main.swift -o main
$ codesign --sign "Apple Development: YYY YYY (***)" --entitlements entitlements.plist main
$ cat entitlements.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>com.domain.appname</string>
    </array>
</dict>
</plist>

It turns out that VSCode lacked the following permissions in the System Settings application:

  • Full Disk Access
  • iTunes/Media Access

Essentially, any application that now uses iTunesLibrary must be manually added in the system settings and require to have these permissions enabled to work. Additionally, if you’re building a proper production app, you should check for these permissions and redirect users to the settings if needed. The program can only run from an environment with the correct permissions (e.g., VSCode or iTerm2 with the appropriate access).

I only needed to add "iTunes/Media Access", not "Full Disk Access". I'd done that for a prior IT app I'd written but forgot the access toggle. I'll suggest they update the docs. [Edit: suggested at FB16323701]

Cannot load iTunesLibrary on macOS Sequoia 15.1
 
 
Q