Just updated to Xcode 12.0 from the last version of Xcode 11/iOS13 and am getting an error in AppDelegate: Thread 1: "Subclass MPMediaItem must implement -valueForProperty: defined in [MPMediaItem class]."
When the app starts, I MPMediaQuery the library for songs and store them to a @Published variable in an Observable Object like this:
@Published var songs = [MPMediaItem]()
init() {
self.songs = MPMediaQuery.songs().items
}
Later when I want to access a property I do so like this:
Text(self.observableObject.songs[0].title)
I’ve tried changing these to use .value(forProperty: "MPMediaItemPropertyTitle") but it doesn’t feel to be use a string over a property (and Xcode then pops up errors like Failed to produce diagnostic for expression; please file a bug report apple.) AFAIK, I’m not subclassing MPMediaItem anywhere and I’ve tried Googling the error above with no luck.
Anyone know what’s going on?
I'm not sure if this is useful to your situation, but I recently came across a simiar problem.
In my case I needed to change 2 things that triggered this crash:
I was initialising an empty
MPMediaItem()as placeholder when no current song was loaded. The crash happened when trying to access a property (e.g.title) on this empty instance. Upon removing the emptyMPMediaItem()and implementing a different placeholder approach, the problem went away.To test music on the simlator I was using a
DummyMediaQuery: MPMediaQuerywhich returned an array ofDummyMediaItem: MPMediaItem. In theDummyMediaItemclass I did: