An iOS framework that provides Music Sensing functionality to your applications. Currently support music data from Apple Music.
The following music item types are currently supported in MusicSenseKit:
- Album
- Track
- Playlist
- Artist
These three music data type can cover most of the usage scenarios of music service.
The following user music data are currently supported in MusicSenseKit:
- Library Albums
- Library Playlists
- Library Artists
- Recently Added Resources
- Recently Added Albums
- Recently Added Playlists
- Recently Played Resources
- Recently Played Albums
- Recently Played Playlists
- Recently Tracks
You can easily install MusicSenseKit Framework by adding a SwiftPM to your Xcode iOS project.
Import and init MusicSenseKit as shown below:
Swift
import MusicSenseKit
let libraryAlbums = try await MusicSenseKit.libraryAlbums()
let recentTracks = try await MusicSenseKit.libraryTracks()
This framework must be run on a physical device (i.e., an iPhone).
Before you run the project in Xcode, perform the following steps:
- In the Project navigator, select the project and click the Signing & Capabilities tab.
- Select your developer team from the Team menu.
- Choose a new bundle identifier for the
Your App
target, and enter it in the Bundle Identifier field. The bundle identifier within the project has an associated App ID, so you need a unique identifier to create your own App ID. Use a reverse-DNS format for your identifier, as Preparing Your App For Distribution describes. - In Safari, visit the Certificates, Identifiers, and Profiles section of the developer web site.
- Select Identifiers and click the Add button to create a new App ID for
Your App
. Follow the steps until you reach the Register an App ID page. - For the Bundle ID, select Explicit, and enter the bundle identifier from step 2.
- Click the App Services tab, and select the MusicKit checkbox.
- Complete the App ID creation process.
After creating your App ID, your Xcode project needs no additional configuration. The App Service is a run-time service that automatically associates with app's bundle ID.
Depending on the used sensor and its configuration, some keys with a user-friendly description should be included in the info.plist application file:
Privacy - Media Library Usage Description: NSAppleMusicUsageDescription
Thanks for Apple Developer Forum and related materials on WWDC that have so many useful information helped me to build this.
For future features, I want to add more data types. Or make it compatible with Spotify.