One Logo Pool Ball
MusicKit · IOS API REFERENCE

MusicLibrary

class · iOS 16.0+ · SDK 27.1

class MusicLibrary

An object your app uses to access the user’s music library.

Members (3)

method · iOS 16.0+

createPlaylist

TypeScript
createPlaylist(name: string, description?: (string) | null, authorDisplayName?: (string) | null): Promise<Playlist>
Swift declaration
@discardableResult func createPlaylist(name: String, description: String? = nil, authorDisplayName: String? = nil) async throws -> Playlist

Creates a playlist in the user’s music library. - Parameters: - name: The name of the playlist. - description: An optional description of the playlist. - authorDisplayName: The display name of the author for the playlist. A `nil` value will result in the framework using your app’s name instead. - Returns: The newly created playlist.

method · iOS 16.0+

edit

TypeScript
edit(playlist: Playlist, name?: (string) | null, description?: (string) | null, authorDisplayName?: (string) | null): Promise<Playlist>
Swift declaration
@discardableResult func edit(_ playlist: Playlist, name: String? = nil, description: String? = nil, authorDisplayName: String? = nil) async throws -> Playlist

Edits a playlist that your app has created. This function will throw an error if your app attempts to edit a playlist that another app created. - Returns: The edited playlist.

get · iOS 16.0+

shared

TypeScript
static get shared(): MusicLibrary
Swift declaration
static let shared: MusicLibrary

A shared object that allows your app to modify the user’s music library.

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

MusicLibrary.add(_:)

This declaration needs Swift generic type arguments. (no canonical witness for MusicItemType)

MusicLibrary.add(_:to:)

This declaration needs Swift generic type arguments. (no canonical witness for MusicItemType)

MusicLibrary.createPlaylist(name:description:authorDisplayName:items:)

This declaration needs Swift generic type arguments. (no canonical witness for S)

MusicLibrary.edit(_:name:description:authorDisplayName:items:)

This declaration needs Swift generic type arguments. (no canonical witness for S)

All MusicKit types →