Search code examples
iosswiftmpmediaplayercontroller

MPMediaPickerController shows white screen , no error


I get a white screen when I try to present MPMediaPickerController. After that, it automatically dismisses itself. I can't access music library in order to import songs in my app.
What is really weird is that there is no error printed out in the console. I am testing on a physical iPhone device.

  @IBAction func importSong(_ sender: Any) {


    let mediaPicker: MPMediaPickerController = MPMediaPickerController.self(mediaTypes: MPMediaType.music)
    mediaPicker.delegate = self
    mediaPicker.allowsPickingMultipleItems = false
    self.present(mediaPicker, animated: true, completion: nil)
}

See video : https://youtu.be/8fjeWXjObPo


Solution

  • Add NSAppleMusicUsageDescription in your Info.plist file, e.g.:

    <key>NSAppleMusicUsageDescription</key>
    <string>App wants to use music</string>