r/iOSProgramming • • 10m ago

App Saturday VoiceOver kept talking into my users' voice recordings. Here's how we fixed it in SwiftUI

Hi everyone. I'm blind, and I'm not a programmer, but I've built Sonnounce, a free app that sends spoken messages to Sonos speakers in your own voice. You hold the button, speak and let go, and the message plays on the speakers you choose. It runs on iPhone, iPad, Apple Watch and Mac.

Tech stack

The app is written in Swift with SwiftUI. UIKit is only used in a few places, like haptics and beginBackgroundTask, so a message can finish sending in the background. Audio is recorded with AVAudioRecorder as 16-bit mono WAV at 22,050 Hz, and background noise can be removed afterwards with Apple's AUSoundIsolation.

Speakers are found with Bonjour (_sonos._tcp) through NWBrowser. SSDP was skipped because it needs a special entitlement from Apple. The app runs its own small web server with NWListener and serves the clip on a random URL. Then it tells the speaker to fetch it with loadAudioClip over Sonos' local websocket on port 1443, so there's no cloud and no account.

Shortcuts use AppIntents, the watch uses WatchConnectivity, and the Mac version is built from the same code with AppKit.

Development challenge

The record button is a SwiftUI DragGesture with minimumDistance 0. Recording starts when your finger touches the button, and the message is sent when you let go. With VoiceOver, Apple's built-in screen reader, you double-tap and hold on the second tap.

The problem: when recording started, the button's text changed to show that it was recording. VoiceOver read the new text out loud, and that speech ended up in the middle of the message on the speakers. You would probably never notice this if you tested with VoiceOver turned off.

The fix was to keep the button's label completely still while recording and clear the instructions, so VoiceOver has nothing new to announce. Haptic feedback tells you when recording starts and stops instead.

A smaller lesson: the "double-tap and hold" instruction is in accessibilityValue, not accessibilityHint. A value is read right after the label, while a hint comes after a pause, or not at all if the user has turned hints off, which a lot of experienced VoiceOver users do.

A second challenge was older Sonos S1 speakers. They don't support audio clips, so the message can't just play on top of the music. For those, the app falls back to plain UPnP/SOAP calls on port 1400. The message interrupts the music for a moment, and the app brings the music back afterwards.

AI disclosure

Mostly or fully AI-generated. I can't write code, so Claude Code wrote it. I describe what I want in plain language, test everything myself, and tell Claude exactly what I hear when something is wrong. That's how I found the VoiceOver bug: I could hear it in my own messages.

The app is free: https://apps.apple.com/app/id6808746158

Happy to answer any questions.

2 Upvotes

0 comments sorted by