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.
Execution model No structured execution marker indexed; callback threading requires source review.
State/event model Source-visible mechanisms: NotificationCenter.
Key frameworks/packages Foundation, UIKit, AVFoundation, MediaPlayer, Cocoa; these are source dependencies, not architecture labels.

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 {

    // A direct reference to this app delegate.

    static private(set) var shared: MacAppDelegate!

    // Initial setup when the app has finished launching.

    func applicationDidFinishLaunching(_ notification: Notification) {

        MacAppDelegate.shared = self

        // Create the data model.

        ConfigModel.shared = ConfigModel(nowPlayableBehavior: MacNowPlayableBehavior())

        // Notify the UI that the model has been changed.

        MacWindowController.shared.updateConfig()
    }

}

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.

Concurrency, scheduling, and thread safety

Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.

No source-visible execution, scheduling, or synchronization boundary was found in the indexed source.

@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.

State propagation, frameworks, and dependencies

Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.

Category Mechanism or module Verified role Evidence
State propagation NotificationCenter NotificationCenter distributes named process-local events. NowPlayable-iOS/NowPlayable/IOSNowPlayableBehavior.swift:65
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. NowPlayable-Mac/NowPlayable/MacNowPlayableBehavior.swift:8
Source import UIKit The cited file imports this module; runtime use and architectural role are not inferred. NowPlayable-iOS/Interface/IOSAppDelegate.swift:8
Source import AVFoundation The cited file imports this module; runtime use and architectural role are not inferred. NowPlayable-Mac/Interface/MacConfigViewController.swift:9
Source import MediaPlayer The cited file imports this module; runtime use and architectural role are not inferred. NowPlayable-Mac/NowPlayable/MacNowPlayableBehavior.swift:9
Source import Cocoa The cited file imports this module; runtime use and architectural role are not inferred. NowPlayable-Mac/Interface/MacAppDelegate.swift:8
Source import AppKit The cited file imports this module; runtime use and architectural role are not inferred. Shared/Configuration/ConfigModel.swift:11

receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.

Class and protocol design

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

protocol CommandCellViewDelegate: AnyObject {
    // ...
    func updateCommandDisabledState(_ configPath: ConfigPath, disabled: Bool)
    // ...
}
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? {
        // ...
        guard let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "EnabledItemCell"),
                                            owner: self) as? MacEnabledItemCellView
        // ...
    }

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 Cited implementation, Cocoa, MacAppDelegate
NowPlayable-iOS/Interface/IOSAppDelegate.swift Cited implementation, UIKit, IOSAppDelegate
Shared/Utility/CommandCellViewDelegate.swift CommandCellViewDelegate
NowPlayable-Mac/Interface/MacConfigViewController.swift Cited implementation, AVFoundation, MacConfigViewController
NowPlayable-iOS/NowPlayable/IOSNowPlayableBehavior.swift Cited implementation, NotificationCenter, IOSNowPlayableBehavior
NowPlayable-iOS/Interface/IOSConfigTableViewController.swift IOSConfigTableViewController
NowPlayable-Mac/NowPlayable/MacNowPlayableBehavior.swift Cited implementation, Foundation, MediaPlayer, MacNowPlayableBehavior
Shared/Configuration/ConfigModel.swift AppKit, ConfigModel
NowPlayable-tvOS/Interface/TVAppDelegate.swift TVAppDelegate
Shared/Player/AssetPlayer.swift AssetPlayer, PlayerState
NowPlayable-Mac/Interface/MacCommandCellView.swift MacCommandCellView
NowPlayable-Mac/Interface/MacEnabledItemCellView.swift MacEnabledItemCellView
NowPlayable-Mac/Interface/MacWindowController.swift MacWindowController
NowPlayable-iOS/Interface/IOSConfigViewController.swift IOSConfigViewController
NowPlayable-tvOS/Interface/TVConfigViewController.swift TVConfigViewController
Shared/Configuration/ConfigCommand.swift ConfigCommand