●BUILD — Rork Max generates native Swift apps, reaching areas React Native struggles to touch●PLATFORM — Rork Max supports iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessage●NATIVE — Tap native features like HealthKit, Core ML, NFC, Dynamic Island, and Live Activities●TEST — A browser-based streaming iOS simulator lets you test without Xcode or a Mac●DEPLOY — Automated builds, certificates, and App Store submission simplify shipping●PRICE — Start free; paid plans begin at $25/month and Rork Max is $200/month●BUILD — Rork Max generates native Swift apps, reaching areas React Native struggles to touch●PLATFORM — Rork Max supports iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessage●NATIVE — Tap native features like HealthKit, Core ML, NFC, Dynamic Island, and Live Activities●TEST — A browser-based streaming iOS simulator lets you test without Xcode or a Mac●DEPLOY — Automated builds, certificates, and App Store submission simplify shipping●PRICE — Start free; paid plans begin at $25/month and Rork Max is $200/month
Using MusicKit in Rork Max Native Swift — Apple Music Authorization, Search, and Playback in a Minimal Setup
Bringing MusicKit into a Rork Max Swift app: MusicAuthorization, catalog search with MusicCatalogSearchRequest, choosing between ApplicationMusicPlayer and SystemMusicPlayer, and handling non-subscribers with previews and offers.
While sketching a focus-music utility, I got stuck on a surprisingly early question: where does the music come from? Third-party streaming SDKs looked tempting, but the review risk and maintenance weight of an external dependency did not add up for an indie developer. So I went with Apple's own MusicKit.
The short version: MusicKit lets you reach the entire Apple Music catalog without running a single server, which makes it an unusually good fit for solo projects. Even developer token issuance and renewal are handled automatically by the framework.
Because Rork Max outputs native Swift, you can walk straight into this territory — no bridging detours like you would need from React Native. Here is the minimal path from authorization to playback, in the order you would actually implement it.
Before Any Code — Two Settings Outside the Project
MusicKit trips people up in configuration before it ever trips them up in code. You need exactly two things.
Enable MusicKit under App Services for your App ID. In the Apple Developer portal, open your App ID under Identifiers and check MusicKit on the App Services tab. This is what authorizes automatic developer token issuance.
Add NSAppleMusicUsageDescription to Info.plist. Explain why you access the user's library. Without it, the app crashes the moment the authorization dialog would appear.
The older way of using the Apple Music API required signing and rotating JWT developer tokens on your own server. Modern Swift MusicKit handles issuance, caching, and renewal automatically once the setup above is in place. That is the entire reason this works serverless.
Authorization — MusicAuthorization.request()
The first code you write is the authorization request. It is a single async call.
import MusicKit@MainActorfinal class MusicAccessModel: ObservableObject { @Published var status: MusicAuthorization.Status = .notDetermined func requestAccess() async { // Shows the dialog on first run; returns the stored decision instantly afterwards status = await MusicAuthorization.request() }}
status is one of .authorized, .denied, .restricted, or .notDetermined. After a .denied, you cannot re-present the dialog from inside the app, so wire up a path to the Settings app via UIApplication.openSettingsURLString.
As for timing: request authorization at the moment the user first touches a music feature, not at launch. Unless music is your app's core purpose, a permission dialog at startup only costs you users.
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦The setup that lets MusicKit manage developer tokens for you, plus working code covering authorization, catalog search, and playback end to end
✦A behavior comparison of ApplicationMusicPlayer versus SystemMusicPlayer — and how the choice reshapes what users actually experience
✦Workarounds for the two classic dead ends: Apple Music non-subscribers and simulator playback, plus the settings Rork Max prompts tend to omit
Secure payment via Stripe · Cancel anytime
✦
Unlock This Article
Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.
Add Album.self or Playlist.self to types for cross-type search. Each returned Song carries the title, artist, artwork URL, and even previewAssets for previews — enough metadata to build your entire results list without further requests.
For artwork, song.artwork?.url(width:height:) returns a size-specific URL. Pass the actual display size instead of loading full-resolution images into list thumbnails; scroll-time memory usage changes noticeably.
Playback — Where ApplicationMusicPlayer and SystemMusicPlayer Diverge
There are two players, and this choice shapes the user experience more than anything else in the integration.
Aspect
ApplicationMusicPlayer
SystemMusicPlayer
Who owns the queue
Your app only (Music app untouched)
Shared with the Music app
When your app quits
Playback stops
Playback continues in the Music app
Best suited for
In-app BGM, music as part of the experience
Handing a song off to the user's music environment
func play(_ song: Song) async throws { // We want playback contained inside the app, so ApplicationMusicPlayer it is let player = ApplicationMusicPlayer.shared player.queue = [song] try await player.play()}
For an in-app experience like focus music, use ApplicationMusicPlayer. For a "play this song" hand-off, use SystemMusicPlayer. In my own first prototype I picked SystemMusicPlayer, and a tester told me it felt eerie that music kept playing after closing the app — I rebuilt it. Intuition and actual behavior diverge easily here, so if you remember one row of that table, make it the first.
Non-Subscribers — Branch on MusicSubscription
Users without an Apple Music subscription cannot play full catalog tracks. You check the state via MusicSubscription.current.
Preview playback. Feed a previewAssets URL into AVPlayer and you can offer roughly 30-second previews with no subscription at all. Search plus preview already stands on its own as a feature.
The subscription offer sheet. SwiftUI's musicSubscriptionOffer(isPresented:options:) modifier presents Apple's standard signup sheet inside your app. If the user subscribes, you transition straight into full playback.
The one design to avoid is hiding the whole feature from non-subscribers. With the three-tier structure — search, preview, offer — every user state has a screen worth showing.
What Rork Max Prompts Tend to Omit
Ask Rork Max simply to "build a BGM app with Apple Music search" and you often get code that is correct yet does not run. The causes live outside the code. Add these two sentences to your prompt:
"Add NSAppleMusicUsageDescription to Info.plist."
"Call MusicAuthorization.request() when the music screen first appears."
Enabling MusicKit on the App ID remains a manual step in the Apple Developer portal — no amount of correct generated code replaces it. If the authorization dialog never appears on a physical device, or search fails with what looks like a 401, check there first.
One more: the simulator cannot play Apple Music content. Search and metadata work fine, so you get the misleading state where everything runs until playback silently fails. Do playback verification on a physical device from the start and you skip a whole detour of false debugging.
Small Notes on Review and Operations
For apps where music playback is the main feature, App Review tends to check whether the app still makes sense for non-subscribers. Implementing previews and the offer sheet is not just good UX — it is review insurance.
Operationally, do not cache the result of MusicSubscription.current for long periods; subscription states change. The call is light enough to refresh on each screen appearance.
A media integration this deep, with zero servers, has almost no alternatives at indie scale. Get just the first two steps working — authorization and search — and feel what it is like to have the entire catalog arrive in your app.
Share
Thank You for Reading
Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.