Sample CodeiOS, iPadOS, Mac Catalyst, macOS, tvOSReviewed 2026-07-21View on Apple Developer

Becoming a now playable app

At a glance

Item Summary
Purpose Ensure your app is eligible to become the Now Playing app by adopting best practices for providing Now Playing info and registering for remote command center actions.
App architecture A Swift sample bundle with entry-bearing project variants NowPlayable-Mac, NowPlayable-iOS, NowPlayable-tvOS, each leading to MediaPlayer APIs.
Main patterns View-controller organization, Protocol-oriented abstraction, Delegate or data-source callbacks
Project style 28 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── NowPlayable-Mac/
│   └── Interface/
│       ├── MacAppDelegate.swift
│       ├── MacCommandCellView.swift
│       ├── MacConfigViewController.swift
│       ├── MacEnabledItemCellView.swift
│       └── MacWindowController.swift
├── NowPlayable-iOS/
│   └── Interface/
│       ├── IOSAppDelegate.swift
│       ├── IOSConfigTableViewController.swift
│       └── IOSConfigViewController.swift
├── NowPlayable-tvOS/
│   └── Interface/
│       ├── TVAppDelegate.swift
│       └── TVConfigViewController.swift
└── Shared/
    ├── Player/
    │   └── AssetPlayer.swift
    └── Configuration/
        └── ConfigCommand.swift

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 12 project/configuration file(s) and 32 source declaration(s).

Overall architecture

Reference code

NowPlayable-Mac/Interface/MacAppDelegate.swift:10 — architecture anchor

@NSApplicationMain
class MacAppDelegate: NSObject, NSApplicationDelegate {
    // ...
}

Interpretation

The branches represent separate entry-bearing project variants in the downloaded bundle, not runtime calls between those variants. Each branch is intentionally collapsed at the documented framework boundary; the detailed target-local flow remains in the cited files. Ownership is claimed only where the next section cites a stored property or assignment.

Ownership and state

Ownership evidence

NowPlayable-iOS/Interface/IOSAppDelegate.swift:20 — stored dependency or nearest verified ownership anchor

@UIApplicationMain
class IOSAppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    var window: UIWindow?
    // ...
}
Owner Object or state Relationship Mutation authority
IOSAppDelegate UIWindow (window) stores or receives App/module collaborators
TVAppDelegate UIWindow (window) stores or receives App/module collaborators
MacCommandCellView NSTextField (commandNameLabel) holds a non-owning reference The referenced object’s lifecycle is owned elsewhere
MacCommandCellView NSButton (disabledButton) holds a non-owning reference The referenced object’s lifecycle is owned elsewhere

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

Shared/Utility/CommandCellViewDelegate.swift:10 — representative type boundary

protocol CommandCellViewDelegate: AnyObject {
    // ...
}
Type Responsibility Depends on or conforms to
MacAppDelegate Receives callback-driven events NSObject, NSApplicationDelegate
IOSAppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate
TVAppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate
CommandCellViewDelegate Defines a capability or collaboration contract AnyObject
EnabledItemCellViewDelegate Defines a capability or collaboration contract AnyObject
AssetPlayer Owns media or timeline playback Concrete collaborators/imported frameworks
MacCommandCellView User-interface presentation and input forwarding NSTableCellView
MacConfigViewController View lifecycle, callbacks, and feature coordination NSViewController, NSTableViewDelegate, NSTableViewDataSource
MacEnabledItemCellView User-interface presentation and input forwarding NSTableCellView
MacWindowController View lifecycle, callbacks, and feature coordination NSWindowController

The source explicitly defines local protocol relationships: MacNowPlayableBehaviorNowPlayable, IOSConfigTableViewControllerCommandCellViewDelegate, IOSConfigTableViewControllerEnabledItemCellViewDelegate, IOSNowPlayableBehaviorNowPlayable, TVNowPlayableBehaviorNowPlayable.

Access control

Symbol Access Verified effect Likely rationale
cellForExternalPlayback (NowPlayable-Mac/Interface/MacConfigViewController.swift:122) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
cellForAsset (NowPlayable-Mac/Interface/MacConfigViewController.swift:138) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
cellForCommand (NowPlayable-Mac/Interface/MacConfigViewController.swift:154) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
interruptionObserver (NowPlayable-iOS/NowPlayable/IOSNowPlayableBehavior.swift:39) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

NowPlayable-Mac/Interface/MacConfigViewController.swift:122 — representative boundary

    private func cellForExternalPlayback(_ tableView: NSTableView, row: Int, item itemIndex: Int) -> NSTableCellView? {
        // ...
    }

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Represents or runs a user/system command ConfigCommand, NowPlayableCommand The source’s Command suffix makes this role explicit.
View lifecycle, callbacks, and feature coordination IOSConfigTableViewController, IOSConfigViewController, MacConfigViewController, MacWindowController The source’s Controller suffix makes this role explicit.
Receives callback-driven events CommandCellViewDelegate, EnabledItemCellViewDelegate, IOSAppDelegate, MacAppDelegate The source’s Delegate suffix makes this role explicit.
Feature data or observable state ConfigModel The source’s Model suffix makes this role explicit.
Owns media or timeline playback AssetPlayer The source’s Player suffix makes this role explicit.
User-interface presentation and input forwarding AssetPlayerView, MacCommandCellView, MacEnabledItemCellView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization NowPlayable-iOS/Interface/IOSConfigTableViewController.swift:10 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Protocol-oriented abstraction NowPlayable-Mac/NowPlayable/MacNowPlayableBehavior.swift:11 A local protocol and concrete conformance create an explicit capability boundary.
Delegate or data-source callbacks NowPlayable-Mac/Interface/MacAppDelegate.swift:11 Callback protocols invert event delivery back into the sample’s owner.

Naming conventions

  • Types: Command: ConfigCommand, NowPlayableCommand; Controller: IOSConfigTableViewController, IOSConfigViewController, MacConfigViewController, MacWindowController, TVConfigViewController; Delegate: CommandCellViewDelegate, EnabledItemCellViewDelegate, IOSAppDelegate, MacAppDelegate, TVAppDelegate; Model: ConfigModel; Player: AssetPlayer; View: AssetPlayerView, MacCommandCellView, MacEnabledItemCellView.
  • Protocols: CommandCellViewDelegate, EnabledItemCellViewDelegate, NowPlayable.
  • Methods: applicationDidFinishLaunching, application, optOut, handlePlayerItemChange, handlePlaybackChange, play, pause, togglePlayPause.
  • Files: NowPlayable-Mac/Interface/MacAppDelegate.swift, NowPlayable-iOS/Interface/IOSAppDelegate.swift, NowPlayable-tvOS/Interface/TVAppDelegate.swift, Shared/Player/AssetPlayer.swift, NowPlayable-Mac/Interface/MacCommandCellView.swift, NowPlayable-Mac/Interface/MacConfigViewController.swift.

Architecture takeaways

  • MacAppDelegate is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches UIKit, AVFoundation, MediaPlayer, Cocoa through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • Local protocol relationships provide an explicit substitution boundary.

Source map

Source file Relevant symbols
NowPlayable-Mac/Interface/MacAppDelegate.swift MacAppDelegate
NowPlayable-iOS/Interface/IOSAppDelegate.swift IOSAppDelegate
NowPlayable-tvOS/Interface/TVAppDelegate.swift TVAppDelegate
Shared/Player/AssetPlayer.swift AssetPlayer, PlayerState
NowPlayable-Mac/Interface/MacCommandCellView.swift MacCommandCellView
NowPlayable-Mac/Interface/MacConfigViewController.swift MacConfigViewController
NowPlayable-Mac/Interface/MacEnabledItemCellView.swift MacEnabledItemCellView
NowPlayable-Mac/Interface/MacWindowController.swift MacWindowController
NowPlayable-iOS/Interface/IOSConfigTableViewController.swift IOSConfigTableViewController
NowPlayable-iOS/Interface/IOSConfigViewController.swift IOSConfigViewController