iOS 16 Music Kit MusicLibrary methods have stopped working

Hi there,

I have a related forum thread here and a Feedback Assistant ticket open, but this issue seems different.

Sometime within the last 2-3 weeks, code related to MusicLibrary has stopped working. None of my code has changed.

For example, the below two snippets used to work fine:

 for track in newTracks { 
   try await MusicLibrary.shared.add(track, to: targetPlaylist)
 }
try await MusicLibrary.shared.edit(targetPlaylist, items: items)

newTracks and items are both fetched using:

try await targetPlaylist.with(.tracks, preferredSource: .catalog).tracks

Using preferredSource: .catalog was a workaround used to address the issue in the aforementioned post above.

All iOS 16 capable functions are decorated with:

@available(iOS 16, *)

or in an if block:

if #available(iOS 16, *) {...

What's happening is that the following is showing up in the console:

2022-11-28 23:31:11.279648+0700 MyApp[38653:6736450] [core] Attempted to register account monitor for types client is not authorized to access: {(
    "com.apple.account.iTunesStore"
)}

2022-11-28 23:31:11.279718+0700 MyApp[38653:6736450] [Default] <ICUserIdentityStoreACAccountBackend: 0x282adb520> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)"

2022-11-28 23:31:11.279758+0700 MyApp[38653:6736450] [Default] ICUserIdentity - Unable to retrieve DSID for userIdentity=<ICUserIdentity 0x2806eb120: [Active Account: <unresolved>]> - error=Error Domain=com.apple.accounts Code=7 "(null)"

These errors are not caught by a do/catch block, but I assume they are related to the issue, and I believe they have to do with MyApp trying to access things that Music Kit thinks it's not supposed to. For example, if MyApp attempts to work with a playlist that it did not create, errors would be expected, thrown errors.

The thing is that I know I'm working with resources that are created by MyApp.

In fact, in trying to test this, I just tried to create a playlist with the below, and the same behavior is occurring:

@available(iOS 16, *)
func createPlaylist2(name: String, description: String) async -> MusicKit.Playlist? {
    do {
        Logger.log(.info, "Creating Playlist: \(name)")
        Logger.log(.shrug, "Does this work?")
        let newPlaylist = try await MusicLibrary.shared.createPlaylist(name: name, description: description)  // <= Things stop here!
        Logger.log(.success, "New playlist created: \(newPlaylist)") // <= this isn't logged.
        return newPlaylist // <= nothing is returned
    } catch {
        Logger.log(.error, "Could not create new playlist: \(error)") // <= no error logged.
    }
    return nil
}

The result is:

2022-11-29 00:15:01.875064+0700 MyApp[38794:6760471] [core] Attempted to register account monitor for types client is not authorized to access: {(
    "com.apple.account.iTunesStore"
)}

2022-11-29 00:15:01.875372+0700 MyApp[38794:6760471] [Default] <ICUserIdentityStoreACAccountBackend: 0x283005720> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)"

2022-11-29 00:15:01.876677+0700 MyApp[38794:6760323] [EntityQuery] Finished executing query in 0.000999928s

2022-11-29 00:15:01.889055+0700 MyApp[38794:6760323] [EntityQuery] Finished fetching results in 0.0120001s

2022-11-29 00:15:01.891235+0700 MyApp[38794:6760329] [core] Attempted to register account monitor for types client is not authorized to access: {(
    "com.apple.account.iTunesStore"
)}

2022-11-29 00:15:01.891684+0700 MyApp[38794:6760329] [Default] <ICUserIdentityStoreACAccountBackend: 0x283005720> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)"

📘 Creating Playlist: TEST PLAYLIST

🤷🏻‍♀️ Does this work?

2022-11-29 00:15:06.697374+0700 MyApp[38794:6760329] [] nw_path_necp_check_for_updates Failed to copy updated result (22)

What's really nasty is that errors are not thrown, so they can't be caught and handled in a catch block.

I know that iOS 16.1 got released around the end of October, but I really don't know what's going on here.

The behavior is showing up in both prod and when testing locally.

Any help would be most appreciated.

@JoeKhun: Did I miss the memo?

Post not yet marked as solved Up vote post of Kimfucious Down vote post of Kimfucious
3.3k views
  • @Kimfucious Now I'm getting same error Can you help me how to fix it?

  • Hi @CMExpertise,

    Unfortunately not. I'm basically a user, same as you.

    While I could be doing something wrong, my best current guess is that this is a transient issue that appears every so often that somehow gets magically resolved.

    @JoeKun or @david-apple don't seem to be replying so perhaps they've moved to other things. Not sure how to get more attention on this issue.

Add a Comment

Replies

@JoeKun I spelled your name wrong 😊 @david-apple any help here?

This started working again, which is mysterious esp. considering I changed no code.

If anyone else has experienced this, please let me know that I'm not alone here.

Just jumping in to say the same thing is happening to me. Earlier today, it was all fine. No code changes. Suddenly, it's broken.

I kinda through it may have had something to do with playing my music on multiple devices, i.e Music app on my computer while coding, and music app on my device while testing.

Stopping the music on one didn't fix this however.

Just to be clear. I can PLAY music just fine. Using the API to search for tracks, or load playlists results in this error.

I am experiencing the same errors:

2023-08-26 13:08:25.080930-0400 TestApp[8604:629650] [core] Attempted to register account monitor for types client is not authorized to access: {(
    "com.apple.account.iTunesStore"
)}
2023-08-26 13:08:25.080969-0400 TestApp[8604:629650] [Default] <ICMonitoredAccountStore: 0x2826bf060> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)"

Confusing part is I AM ABLE to load my playlists, the songs within each playlist, and all songs in my library. I am also able to play songs without any issue. The errors seem harmless for my use case, but does anyone know if I will have problems going forward? Or better yet, how to resolve these "errors"? :)

  • I Have same issue @vaneron Did You get any alternative way or solution?

Add a Comment

I saw it recently again too.

My best guess is that some transient issue that gets quietly fixed or magically resolves itself.

The real bug-a-boo here is that errors are not thrown, so I cannot catch and deal with them to provide users with any type of error message, which equates to a bad user experience.

  • Save issue here.

Add a Comment

are you guys able to fix it? I have added media id for my app id, fingers crossed hope it fixes the issue in few hours.