Post

Replies

Boosts

Views

Activity

Reply to Cannot load iTunesLibrary on macOS Sequoia 15.1
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).
1w