Cannot load underlying module for 'MediaPlayer'

I'm getting the following error in Xcode and I can't figure out how to fix it.

Cannot load underlying module for 'MediaPlayer'

I've searched Google and have come across lots of other people with similar issues whereby they're importing something and it's producing this error alongside it.

The error is being shown inline with this bit of code:

import SwiftUI
import MusicKit
import MediaPlayer <-- this line here

I can build and run the project without issue and it disappears. But will quickly reappear again a short while later and it's very annoying.

How can I resolve this please?

I have the same probem, i'm using the Version 14.3.1 (14E300c) of Xcode, i thing it's a bug in this version of xcode, i resolved the problem, click in other file in your proyect that dont import MediaPlayer, and then close xcode, opent it againt and run your proyect, it will be working fine.

Cannot load underlying module for 'MediaPlayer'
 
 
Q