
Musickit
Wire Apple Music catalog search, subscription checks, queue playback, and lock-screen Now Playing into a Swift iOS app with MusicKit and MediaPlayer.
Install
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill musickitWhat is this skill?
- Covers setup, authorization, catalog search, subscription checks, ApplicationMusicPlayer playback, and queue management
- Documents MPNowPlayingInfoCenter and MPRemoteCommandCenter for lock-screen and accessory controls
- Targets Swift 6.3 and iOS 26+ with explicit capability, Info.plist, and background audio mode steps
- Includes Common Mistakes and a Review Checklist section for pre-ship validation
- Split imports: MusicKit for catalog/auth/playback and MediaPlayer for system Now Playing APIs
Adoption & trust: 1.2k installs on skills.sh; 713 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
MusicKit work happens while implementing product features, not during idea or launch-only marketing tasks. The skill is centered on third-party platform APIs (MusicKit entitlements, ApplicationMusicPlayer, remote commands), which maps to integrations on the build shelf.
Common Questions / FAQ
Is Musickit safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Musickit
# MusicKit Search the Apple Music catalog, manage playback with `ApplicationMusicPlayer`, check subscriptions, and publish Now Playing metadata via `MPNowPlayingInfoCenter` and `MPRemoteCommandCenter`. Targets Swift 6.3 / iOS 26+. ## Contents - [Setup](#setup) - [Authorization](#authorization) - [Catalog Search](#catalog-search) - [Subscription Checks](#subscription-checks) - [Playback with ApplicationMusicPlayer](#playback-with-applicationmusicplayer) - [Queue Management](#queue-management) - [Now Playing Info](#now-playing-info) - [Remote Command Center](#remote-command-center) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) - [References](#references) ## Setup ### Project Configuration 1. Enable the **MusicKit** capability in Xcode (adds the `com.apple.developer.musickit` entitlement) 2. Add `NSAppleMusicUsageDescription` to Info.plist explaining why the app accesses Apple Music 3. For background playback, add the `audio` background mode to `UIBackgroundModes` ### Imports ```swift import MusicKit // Catalog, auth, playback import MediaPlayer // MPRemoteCommandCenter, MPNowPlayingInfoCenter ``` ## Authorization Request permission before accessing the user's music data or playing Apple Music content. Authorization is a one-time prompt per app install. ```swift func requestMusicAccess() async -> MusicAuthorization.Status { let status = await MusicAuthorization.request() switch status { case .authorized: // Full access to MusicKit APIs break case .denied, .restricted: // Show guidance to enable in Settings break case .notDetermined: break @unknown default: break } return status } // Check current status without prompting let current = MusicAuthorization.currentStatus ``` ## Catalog Search Use `MusicCatalogSearchRequest` to search the Apple Music catalog. The user must have an Apple Music subscription for full catalog access. ```swift func searchCatalog(term: String) async throws -> MusicItemCollection<Song> { var request = MusicCatalogSearchRequest(term: term, types: [Song.self]) request.limit = 25 let response = try await request.response() return response.songs } ``` ### Displaying Results ```swift for song in songs { print("\(song.title) by \(song.artistName)") if let artwork = song.artwork { let url = artwork.url(width: 300, height: 300) // Load artwork from url } } ``` ## Subscription Checks Check whether the user has an active Apple Music subscription before offering playback features. ```swift func checkSubscription() async throws -> Bool { let subscription = try await MusicSubscription.current return subscription.canPlayCatalogContent } // Observe subscription changes func observeSubscription() async { for await subscription in MusicSubscription.subscriptionUpdates { if subscription.canPlayCatalogContent { // Enable full playback UI } else { // Show subscription offer } } } ``` ### Offering Apple Music Present the Apple Music subscription offer sheet when the user is not subscribed. ```swift import MusicKit import SwiftUI struct MusicOfferView: View { @State private var showOffer = false var body: some View { Button("Subscribe to Apple Music") { showOffer = true } .musicSubscriptionOffer(isPresented: $showOffer) } } ``` ## Playback with ApplicationMusicPlayer `ApplicationMusicPlayer` plays Apple Music content independently from the Music app. It does not affect the system player's state. ```swift let player = ApplicationMusic