iOS Media, ML, and Physical Inputs
Use this skill to turn a camera frame, audio stream, imported asset, model, NFC tag, music catalog request, or acoustic match into a bounded, reviewable product flow. Keep this pipeline explicit:
authorized source -> bounded input -> cancellable processing -> observation/prediction/match -> provenance/review -> durable result or user-confirmed side effect
Read before acting
- Inspect the actual Xcode targets, deployment target, device family, scene/lifecycle model, capabilities, entitlements,
Info.plist usage descriptions, model assets, media formats, persistence, and existing capture/playback adapters.
- Read the knowledge-base map, media/camera/sensor route, media and ML deep dive, and media/ML recipes.
- For AI availability and fallback, read privacy, availability, safety, and fallback. For proof levels, read the build/device/release checklist and permission/entitlement/privacy checklist.
- Refresh the exact official Apple pages in the Sources section before relying on an API spelling, availability annotation, entitlement, codec, model runtime, music access rule, NFC behavior, or iOS 26 claim.
Route workflow
- State the user outcome and source ownership: live camera/microphone, imported file, app-owned media, model asset, external NFC tag, Apple Music catalog/account, or ambient audio.
- Choose the narrowest route. Use AVKit/AVFoundation for playback/capture/session state; Core Image for image recipes/rendering; VideoToolbox only for low-level codec control; Vision for system observations; Core ML for a packaged model; Natural Language for locale-aware text analysis; Core NFC for a foreground tag-reader session; MusicKit for Apple Music authorization/catalog/playback; ShazamKit for acoustic matching.
- Record target configuration before implementation: permission and usage description, capability/entitlement, supported formats, model availability, locale, account/subscription state, and physical-device requirement. Mark unverified items as
to-verify.
- Draw the state machine. Keep permission, source/session readiness, model/asset readiness, processing, result review, persistence, and cleanup as separate states. Include denial, unavailable hardware, malformed input, interruption, timeout, cancellation, no match, no subscription, and retry.
- Bound the work. Coalesce or drop stale live frames; limit image/audio duration and dimensions; limit NFC payload length; use cancellation checks; avoid one unbounded task per frame; stop capture and release resources when the feature ends.
- Attach provenance to every result: source identifier, capture/import time, orientation and preprocessing, request/model/revision, locale, confidence or quality when provided, and user review/edit state. Keep an observation, prediction, match, catalog response, or tag payload distinct from domain truth.
- Define privacy and retention before logging or persistence. Prefer local processing, redact media/text/audio/model outputs from diagnostics, delete raw inputs when no longer needed, and do not add analytics, upload, account access, or telemetry without a product reason and authorization.
- Verify in layers: compile against the actual SDK, test deterministic fixtures, test denied/interrupted/unavailable states, then exercise the real camera/microphone/audio route/NFC tag/Apple account on representative physical devices. Record device, OS, model, fixture, latency, dropped inputs, memory, battery, and thermal observations instead of claiming generic “real-time” or “on-device” behavior.
Fast path
Prove the bounded lifecycle with a fixture source before live capture: one input -> one validated output -> cancellation and teardown. Add only the permission and physical route required by that slice, and measure queue, memory, and backpressure behavior rather than recording a successful frame as completion.
Framework boundaries
Media and image processing
AVPlayer/AVPlayerItem and AVPlayerViewController own playback state and native playback surfaces, not business truth or guaranteed first-frame/audio-route availability. Handle buffering, failure, end, interruption, route changes, external playback, and lifecycle transitions.
CIImage is a lazy recipe. A CIContext renders it; reuse an appropriate context, but isolate mutable CIFilter instances from concurrent access. Preserve orientation, color space, and destination format.
- VideoToolbox is a low-level compression/decompression path. Model session creation, property configuration, frame submission, callback completion, pending-frame drain, invalidation, timestamps, pixel formats, and cleanup. Prefer higher-level AVFoundation when direct codec control is not the product need.
Vision, Core ML, and Natural Language
- Vision observations are proposals derived from a request, image orientation, revision, and preprocessing. Preserve the source and request metadata; provide review for consequential writes. OCR text, labels, face/pose observations, and coordinates do not prove identity, safety, intent, or medical/legal truth.
- Core ML model loading, compiled assets, input/output shapes, normalization, model version, and
MLModelConfiguration.computeUnits are explicit runtime state. Compute-unit selection is a policy, not a promise of Neural Engine use, accuracy, latency, or thermal safety. Load asynchronously when appropriate and measure representative hardware.
- Natural Language routes depend on locale, tokenizer/model revision, text limits, and task fit. Keep sensitive text local where possible and distinguish tokenization, language identification, tagging, embeddings, or classification from a generative or factual conclusion.
NFC, MusicKit, and ShazamKit
- Core NFC is a user-mediated foreground reader session. Validate the entitlement, usage description, supported formats/protocols, session timeout/invalidation, multiple tags, unsupported tags, and physical-device behavior. NDEF records and tag responses are untrusted bytes; a tag is not authenticity, payment, identity, ownership, or location proof.
- MusicKit has separate authorization, Apple Music capability/subscription, catalog, user-token/account, playback, and interruption state. Request informed consent, handle denial and account changes, preserve catalog provenance, and do not equate a catalog result with ownership or licensing.
- ShazamKit returns a match, no-match, or error from an acoustic signature. A match means resemblance to the selected catalog under the tested conditions; it is not speaker identity, recording ownership, legal clearance, or universal recognition. Stop matching when the feature ends and avoid retaining raw audio when a signature/result is sufficient.
Non-negotiable safety and evidence rules
- Never present model output, OCR, object/face/pose observation, Natural Language result, NFC payload, MusicKit catalog response, or ShazamKit match as identity, authenticity, medical truth, legal truth, guaranteed accuracy, or authorization without a separate validated domain workflow.
- Never claim camera/microphone/NFC/codec/model support, Apple Music availability, audio/video synchronization, “real time,” “on-device,” battery life, or thermal safety from a preview, simulator, fixture, successful compile, or single device.
- Keep source authorization separate from output validity. Permission granted does not mean a usable session; a ready player does not mean rendered output; a loaded model does not mean a valid prediction; a detected tag does not mean trusted data; MusicKit authorization does not mean a subscription; a match does not mean legal or user identity.
- Treat every external or user-controlled input as untrusted. Bound data size and duration, validate types/schemes/commands/shapes, reject malformed payloads, and require confirmation before consequential side effects.
- Stop and clean up capture, playback, reader sessions, model tasks, signatures, and codec sessions on cancellation, view disappearance, interruption, session invalidation, and task expiration. Keep task ownership explicit so stale results cannot overwrite newer state.
Deliverable
Produce a compact route note or implementation change containing:
- selected framework and rejected alternatives;
- target/device, permission, usage-description, capability, entitlement, model/media-format, account/subscription, and privacy matrix;
- session/model/processing/result state machine with cancellation, backpressure, cleanup, retry, and fallback;
- provenance and review policy for every generated observation/prediction/match;
- source links and exact compile, fixture, physical-device, performance, privacy, signing, and release evidence plan;
- remaining
to-verify gaps and any claims deliberately not made.
For implementation, change only the requested target and directly related adapters/configuration. Do not add a model download, cloud upload, account, Apple Music access, microphone/NFC permission, background mode, analytics, logging of sensitive inputs, or entitlement without a stated user-facing need and authorization.
Related routes and recipes
- Media, camera, and sensor routes
- Media, Vision, Core ML, NFC, and Music deep dive
- Media, Vision, Core ML, NFC, and Music recipes
- Privacy, availability, safety, and fallback
- Permission, entitlement, and privacy checklist
- Build, device, and release checklist
Sources