MusicKit compatibility with macOS

I'm trying to build a small toy MusicKit app on macOS Ventura (beta 4), and am running into something I think is probably an easy issue. I've started with the single-view application template, and have added a button, the target of which calls MusicKit methods:

@IBAction func buttonPushed(_ sender: Any) {

    Task {
      let status = await MusicAuthorization.request()
      switch status {
      case .authorized:
        print("auth")
      case .restricted:
        print("restricted")
      case .notDetermined:
        print("not determined")
      case .denied:
        print("denied")
      @unknown default:
        print("default")
      }
      print(MusicAuthorization.currentStatus)
    }
}

I have added the NSAppleMusicUsageDescription key to the application's Info.plist

However, I am always seeing that MusicAuthorization.request() returns denied with no prompt to the user for access. Thank you in advance.

Answered by dutton in 722964022

Apologies if it's a bit obvious but probably the first thing to check is that you've actually granted permission for your app to access Apple Music on your Mac.

i.e. in the System Preferences app, Security & Privacy -> Privacy -> Media & Apple Music. Is your app listed there and is access enabled?

Just to confirm, this call is working Ok for me on Ventura (unlike any of the newer MusicKit functions).

Sorry, it's been a few days since I did this, but I should mention that I created an App Id with MusicKit enabled, and am signing the app with a provisioning profile created for that App Id.

Accepted Answer

Apologies if it's a bit obvious but probably the first thing to check is that you've actually granted permission for your app to access Apple Music on your Mac.

i.e. in the System Preferences app, Security & Privacy -> Privacy -> Media & Apple Music. Is your app listed there and is access enabled?

Just to confirm, this call is working Ok for me on Ventura (unlike any of the newer MusicKit functions).

Ha! That fixed it. How embarrassing. However, I'd expected a dialogue presented by the macOS or MusicKit asking for access to the Media library, similar to iOS, and it doesn't seem usable to ship something that requires the user to add the app to that list manually. Thank you!

You have to allow access to both Media Library access and Music access, there are two diffent keys. Are you building this app for MacOS? how you going to play apple music item then since there is absolutely no player

MusicKit compatibility with macOS
 
 
Q