xcode swift playground screenshot

(By way of background I have been helping a local blind child learn coding. He's switching schools from a Windows based school to a Mac based school so I am trying to familiarise myself with VoiceOver on the Mac.)

I have a very simple Swift Playground in Xcode which I am trying to build and run using VoiceOver.

var rate = 26
var hours = 12.5
var cost = Double(rate) * hours

As I type that last line VoiceOver reads what I am typing. I then use the keyboard shortcut Shift Command Enter (⇧⌘↵) to run the playground. VoiceOver announces "Run Playground" but does not read the resulting output. I cannot work out how to get it to read the result nor how to navigate to that bottom pane where it might read "325". How would I do either of those things?


1 Answer 1


It's really cool that you're helping a blind person learn how to code! There must be some approach to gather the output in the Xcode console, but it is certainly possible that XCode may lack VoiceOver support for it.

Nevertheless, I'm wondering if you can't take advantage of the built-in VoiceOver functions in a clever way.

Something like:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, cost);

Essentially, just replacing print with a manual UIAccessibilityPostNotification.

  • I had to use UIAccessibility.post(notification: .announcement, argument: cost) and, although that compiles, it failed to make any announcement in an XCode playground under VoiceOver
    – dumbledad
    Sep 20, 2019 at 9:53
  • @dumbledad hmm. I don't know if cost needs to be a string or not (I haven't used UIAccessibility) or if a different setting needs to be activated for that to work. That being said, I found another -- probably better -- option for you in the same vein. Add AVFoundation framework to your project and use AVSpeechSynthesizer. There's an entire sample project demonstrating this here, and looks quite easy to implement: code.tutsplus.com/tutorials/…
    – dxdc
    Sep 20, 2019 at 13:03
  • Another great tutorial here! nshipster.com/avspeechsynthesizer
    – dxdc
    Sep 20, 2019 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .