Night & AirSDKContact team

Platform guide · Swift

iOS integration

Give a completed recording to a Swift session and read the accepted sound intervals on the same device.

Add the Swift package

The iOS pilot uses Xcode 15 or later and targets iOS 13 or later. Request the iOS pilot package for your host app. Extract the supplied package. In Xcode, select File → Add Package Dependencies → Add Local, choose the folder containing Package.swift, and add the NightAirSnore product to your target.

Analyze a mono PCM file

Run this function on a serial background worker after closing the recording. The Apple file reader accepts mono, linear-PCM WAV, AIFF and CAF files.

import Foundation
import NightAirSnore

func review(_ url: URL) throws -> (SnoreSummary, [SnoreEvent]) {
    let session = try SnoreSession()
    try session.addPCMFile(at: url, startFrame: 0)
    let result = try session.finish()
    let events = try (0..<result.eventCount).map {
        try session.event(at: $0)
    }
    return (result, events)
}

Keep the recording timeline

For recordings in several files, call addPCMFile(at:startFrame:) for each original part before calling finish(). At 16 kHz, the frame after ten continuous seconds is 160,000. If capture then pauses for two seconds, the next part starts at 192,000.

For compressed input, decode logical mono Float32 frames and supply a seekable reader with addPart(sampleRate:startFrame:frameCount:read:). Remove codec padding when calculating the frame count. The SDK may request a range more than once.

Verify the Apple build

Swift package tests and an independent SwiftPM consumer passed on Linux. The Apple audio-file adapter, binary packaging and physical iPhone run still require validation with Xcode. Use the reference WAV for the first device run. Record SnoreSDK.version, SnoreSDK.modelVersion and SnoreSDK.configurationID alongside the result.

Next guideAndroid · Kotlin