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.
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).