# Musickit

Integrate Apple Music playback, catalog search, and Now Playing metadata using MusicKit...

- Repository: https://github.com/dpearson2699/swift-ios-skills (1266 stars)
- Category: Mobile
- License: see repository
- Last updated: 2026-07-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add dpearson2699/swift-ios-skills --skill musickit -g -a claude-code -y`
Codex: `npx skills add dpearson2699/swift-ios-skills --skill musickit -g -a codex -y`
Cursor: `npx skills add dpearson2699/swift-ios-skills --skill musickit -g -a cursor -y`
Gemini CLI: `npx skills add dpearson2699/swift-ios-skills --skill musickit -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add dpearson2699/swift-ios-skills`

## Description

Integrate Apple Music playback, catalog search, and Now Playing metadata using MusicKit and MediaPlayer. Use when adding music search, Apple Music subscription flows, queue management, playback controls, remote command handling, or Now Playing info to iOS apps.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# MusicKit

Search the Apple Music catalog, manage playback with `ApplicationMusicPlayer`,
check subscriptions, and publish Now Playing metadata via `MPNowPlayingInfoCenter`
and `MPRemoteCommandCenter`.

## Contents

- [Setup](#setup)
- [Workflow](#workflow)
- [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)

## Workflow

1. Verify the MusicKit App Service, bundle identifier, purpose string, and background-audio mode before debugging code.
2. Request authorization, then model every non-authorized state explicitly.
3. Search or load catalog content and check `MusicSubscription.current` before queueing playback.
4. Choose `ApplicationMusicPlayer` for app-scoped playback; wire Now Playing and remote commands only when the app owns those surfaces.
5. Test authorized, denied, unsubscribed, offline, queue failure, interruption, and track-change states. Fix the smallest failing layer, restore the fixture, and rerun the same state matrix.

## Setup

### Project Configuration

1. Enable the **MusicKit App Service** for the app's explicit bundle ID in the Apple Developer portal so MusicKit can generate developer tokens automatically.
2. Add `NSAppleMusicUsageDescription` to Info.plist explaining why the app accesses the user's media library.
3. For background playback, add the `audio` background mode to `UIBackgroundModes`.

### Imports

```swift
import MusicKit       // Catalog, auth, playback
import MediaPlayer    // MPRemoteCommandCenter, MPNowPlayingInfoCenter
```

## Authorization

The rest: https://github.com/dpearson2699/swift-ios-skills/blob/HEAD/skills/musickit/SKILL.md
