Xcode 14.3.1+ Bug: App crashes on launch iOS 16.0 - MediaPlayer

I imported the MediaPlayer framework and used MPMusicPlayerPlayParameters in my SwiftUI project.

While the app is launching, If the app is built by Xcode 14.3.1 or a newer version, it instantly crashes on a simulator or on a real device.

This problem persists on iOS 16.0 to 16.4. (I haven't tried iOS 15 or below) I also tried to build and run the app with Xcode 15 - beta 4 however it still crashes.

Because of this reason, I archive and submit to App Store with Xcode 14.2. (the built made by Xcode 14.2 works perfectly!!)

Here is the error message:

dyld[17235]: Symbol not found: _$sSo27MPMusicPlayerPlayParametersCSe05MediaB0Mc

  Referenced from:
 <77FEF170-9C51-3580-8F8B-2ADD2F1B3FD1> /Users/[UserName]/Library/Developer/CoreSimulator/Devices/72CE26D8-4DD4-4319-B0C7-DE52D6645875/data/Containers/Bundle/Application/C808623F-5372-40F0-907F-E86E12AE6EDD/[AppName].app/[AppName]

  Expected in:    
 <06F636E1-695C-34F1-809D-7CA24F67AFE9> /Library/Developer/CoreSimulator/Volumes/iOS_20B72/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 16.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MediaPlayer.framework/MediaPlayer

I believe this is Apple related issue however if there is any way that can fix the issue, please let me know.

Is the value media or Media? Also, post the code snippet showing the usage for the class MPMusicPlayerPlayParameters regarding how the dictionary is being created. Take a look here as well: https://developer.apple.com/forums/thread/687819

@MobileTen what do you mean by "Is the value media or Media?" I created a class called MediaManager.

There is no build errors or anything. There is no issue on Xcode 14.2 but for some reason on Xcode 14.3.1 or later, Apple's MediaPlayer framework could not find MPMusicPlayerPlayParameters and results crash while launching the app. I guess MediaPlayer framework is a dynamic framework and that is the reason why it fails on Run Time.

Following iOS versions are affected; 16.0, 16.1 and 16.2. (I couldn't test on iOS 16.3 or iOS 15) However it doesn't crash on iOS 16.4 or later.

I checked the link and here is how I get the dictionary:

import MusicKit
import MediaPlayer

/// ...

    var tracksInQueue: MPMusicPlayerPlayParametersQueueDescriptor = .init(playParametersQueue: [])

/// ...

    func getPlayParameters(from playParameters: PlayParameters?) -> MPMusicPlayerPlayParameters? {
        guard let playParameters = playParameters,
              let data = try? JSONEncoder().encode(playParameters),
              let playParameters = try? JSONDecoder().decode(MPMusicPlayerPlayParameters.self, from: data) else {
            return nil
        }
        return playParameters
    }

    func prepareQueue() {
        DispatchQueue.global(qos: .utility).async { [weak self] in
            guard let self else {
                return
            }
            self.tracksInQueue = MPMusicPlayerPlayParametersQueueDescriptor(playParametersQueue: self.tracks.compactMap {
                self.mediaManager.getPlayParameters(from: $0.playParameters)
            })

            self.tracksInQueue.startItemPlayParameters = self.tracksInQueue.playParametersQueue.first
           
           // queue is ready will be played when user presses the play button
        }

/// ...
    }

@MobileTen Since my answer is long, I replied to the post .

Xcode 14.3.1+ Bug: App crashes on launch iOS 16.0 - MediaPlayer
 
 
Q