iOS Speech Error on Mobile Simulator (Error fetching voices)

I'm writing a simple app for iOS and I'd like to be able to do some text to speech in it. I have a basic audio manager class with a "speak" function:

import Foundation
import AVFoundation

class AudioManager {
    static let shared = AudioManager() 
    
    var audioPlayer: AVAudioPlayer?
    var isPlaying: Bool {
        return audioPlayer?.isPlaying ?? false
    }
    var playbackPosition: TimeInterval = 0
    
    func playSound(named name: String) {
        guard let url = Bundle.main.url(forResource: name, withExtension: "mp3") else {
            print("Sound file not found")
            return
        }
        
        do {
            if audioPlayer == nil || !isPlaying {
                audioPlayer = try AVAudioPlayer(contentsOf: url)
                audioPlayer?.currentTime = playbackPosition
                audioPlayer?.prepareToPlay()
                audioPlayer?.play()
            } else {
                print("Sound is already playing")
            }
        } catch {
            print("Error playing sound: \(error.localizedDescription)")
        }
    }
    
    func stopSound() {
        if let player = audioPlayer {
            playbackPosition = player.currentTime
            player.stop()
        }
    }
    
    func speak(text: String) {
        let synthesizer = AVSpeechSynthesizer()
        let utterance = AVSpeechUtterance(string: text)
        utterance.voice = AVSpeechSynthesisVoice(language: "en-GB")
        synthesizer.speak(utterance)
    }
}

And my app shows text in a ScrollView:

  ScrollView {
      Text(self.description)
          .padding()
          .foregroundColor(.black)
          .font(.headline)
          .background(Color.gray.opacity(0))
  }.onAppear {
      AudioManager.shared.speak(text: self.description)
  }

However, the text doesn't get read out (in the simulator). I see some output in the console:

Error fetching voices: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "Invalid container metadata for _UnkeyedDecodingContainer, found keyedGraphEncodingNodeID", underlyingError: nil)). Using fallback voices.

I'm probably doing something wrong here, but not sure what.

I'm getting same error when running simulator in Xcode 26.1.1. Anyone who can help with this? Not sure this is something I can safely ignore.

On my end, Xcode 26.1.1 can synthesize for the first time then never, will have to restart app. With Xcode 26.2, synthesis outright stopped working. Tried older simulators down to 18.2, no luck. I am on macOS 26.1

The only thing that worked is through writing to a file instead of asking it to speak directly. That will work every time

Speaking directly in a macOS app also doesn't work

After upgrading to macOS 26.2, speaking programmatically in a macOS app still doesn't work, it doesn't work either on iOS simulators. If you synthesize to a file (.caf) and play it back then it will work every time on iOS 26.2 simulator (didn't test on other versions but should work)

turns out, it could be a behavior change

before:

AVSpeechSynthesizer().speak(AVSpeechUtterance(string: "hello word"))

probably after some behaviour change which is also a good change, the playback will also tie with the life span of the AVSpeechSynthesizer instance that starts it. so you will need to find somewhere to hold the instance, otherwise the instance will go out of scope

after:

@state var synthesizer: AVSpeechSynthesizer?

// ...

synthesizer = AVSpeechSynthesizer()
synthesizer?.speak(AVSpeechUtterance(string: "hello word"))

existing tutorials and articles will need to be updated or everyone might land on this page (or llm might take a clue of this or directly point to this)

iOS Speech Error on Mobile Simulator (Error fetching voices)
 
 
Q