Configures AVAudioSession categories, modes, route changes, and interruptions. Builds low-latency AVAudioEngine node graphs for recording, mixing, and audio processing in iOS/iPadOS apps.
Ships in all-ios-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Configure AVAudioSession and construct AVAudioEngine node graphs for playback, recording, real-time DSP, and multi-track audio pipelines in iOS and iPadOS.
AVAudioSession coordinates app audio with the system audio subsystem. Defer activation until playback or recording begins to avoid prematurely silencing background audio.
import AVFAudio
@MainActor
final class AudioSessionManager {
static let shared = AudioSessionManager()
func configurePlayback() throws {
let session = AVAudioSession.sharedInstance()
try session.setCategory(.playback, mode: .moviePlayback, options: [])
try session.setActive(true)
}
func configureRecording() throws {
let session = AVAudioSession.sharedInstance()
try session.setCategory(
.playAndRecord,
mode: .measurement,
options: [.defaultToSpeaker, .allowBluetoothHFP]
)
try session.setActive(true)
}
func deactivate() throws {
try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
}
}
.playback: Media playback that continues when the Ring/Silent switch is set to silent or screen locks..record: Pure recording without playback; silences background audio..playAndRecord: Bidirectional audio (VoIP, chat, audio recording while monitoring). Use .defaultToSpeaker to prevent routing audio only to receiver..ambient: Mixes with other audio apps; silenced by Ring/Silent switch.Always observe AVAudioSession.interruptionNotification and AVAudioSession.routeChangeNotification asynchronously using NotificationCenter async sequences.
import AVFAudio
actor AudioNotificationObserver {
private var task: Task<Void, Never>?
func startObserving(
onInterruption: @Sendable @escaping (Bool) -> Void,
onPauseForRouteLoss: @Sendable @escaping () -> Void
) {
task = Task {
for await notification in NotificationCenter.default.notifications(named: AVAudioSession.interruptionNotification) {
guard let userInfo = notification.userInfo,
let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt,
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { continue }
switch type {
case .began:
onInterruption(true)
case .ended:
let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt ?? 0
let shouldResume = AVAudioSession.InterruptionOptions(rawValue: optionsValue).contains(.shouldResume)
onInterruption(!shouldResume)
@unknown default:
break
}
}
}
}
func stopObserving() {
task?.cancel()
task = nil
}
}
Pause playback immediately when AVAudioSessionRouteChangeReasonKey indicates .oldDeviceUnavailable (e.g., headphones disconnected).
AVAudioEngine coordinates a graph of AVAudioNode instances (player nodes, mixer nodes, effect nodes) connected together.
import AVFAudio
@MainActor
final class AudioEngineController {
private let engine = AVAudioEngine()
private let playerNode = AVAudioPlayerNode()
func setupGraph(audioFileURL: URL) throws {
let file = try AVAudioFile(forReading: audioFileURL)
let format = file.processingFormat
engine.attach(playerNode)
engine.connect(playerNode, to: engine.mainMixerNode, format: format)
try engine.start()
playerNode.scheduleFile(file, at: nil) {
// Playback completed
}
playerNode.play()
}
func stop() {
playerNode.stop()
engine.stop()
engine.reset()
}
}
To analyze or stream microphone PCM buffers, install an audio tap on the inputNode. Always remove previous taps before installing a new tap or tearing down.
import AVFAudio
final class MicrophoneTapManager: Sendable {
private let engine = AVAudioEngine()
func startTapping(bufferHandler: @escaping @Sendable (AVAudioPCMBuffer, AVAudioTime) -> Void) throws {
let inputNode = engine.inputNode
let format = inputNode.outputFormat(forBus: 0)
inputNode.removeTap(onBus: 0)
inputNode.installTap(onBus: 0, bufferSize: 1024, format: format) { buffer, time in
bufferHandler(buffer, time)
}
engine.prepare()
try engine.start()
}
func stopTapping() {
engine.inputNode.removeTap(onBus: 0)
engine.stop()
}
}
installTap(onBus:bufferSize:format:) on a bus that already has a tap installed crashes at runtime. Always call removeTap(onBus:) first.AVAudioEngineConfigurationChange by rebuilding graph or restarting the engine.AVAudioSession configuration set appropriate category, mode, and options (.defaultToSpeaker, .allowBluetoothHFP)?setActive(true) deferred until audio playback/recording actually starts?setActive(false, options: .notifyOthersOnDeactivation) invoked when stopping to restore other audio apps?.oldDeviceUnavailable?.began and .ended with .shouldResume) handled gracefully?AVAudioApplication.requestRecordPermission() prior to starting?What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
avaudioengine, avaudiosession, ios-audio, audio-processing, swift
/all-ios-skills:avfoundation-audiofrom all-ios-skills
npx claudepluginhub thienqo/ios-skills --plugin all-ios-skills95 skills in this plugin
/accessorysetupkitDiscover and configure Bluetooth and Wi-Fi accessories using AccessorySetupKit. Use when presenting a privacy-preserving accessory picker, defining discovery descriptors for BLE or Wi-Fi devices, handling accessory session events, migrating from CoreBluetooth permission-based scanning, or setting up accessories without requiring broad Bluetooth permissions./activitykitBuild or review Live Activities and Dynamic Island experiences with ActivityKit, including lifecycle, layouts, push updates, and scheduled delivery. Use for time-sensitive Lock Screen or Dynamic Island state; route ordinary widgets to widgetkit./adattributionkitMeasure ad effectiveness with privacy-preserving attribution using AdAttributionKit. Use when registering ad impressions, handling attribution postbacks, updating conversion values, implementing re-engagement attribution, configuring publisher or advertiser apps, or replacing SKAdNetwork with AdAttributionKit for ad measurement.Other plugins' skills for the same job