How to use AVSpeechSynthesizer on watchOS

According to documentation, AVSpeechSynthesizer seems available on the watchOS 2/3.

However, when I do


@import AVFoundation


in the watchkit extension target, it complains that CoreMedia is not available and it's included in AVAsset.h


/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator3.0.sdk/System/Library/Frameworks/
AVFoundation.framework/Headers/AVAsset.h:16:9:
'CoreMedia/CMTime.h' file not found


So is this possible and if yes - how to use it.

Replies

This appears to be an issue when attemtpting to build for the Simulator. If you build for the device you won't run into the file not found issue. I'm quite sure this is known and will be addressed in an Xcode update.

I am also encountering the same issue in the XCode 8.1 GM and Xcode 8 when using the simulator.



<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/AVFoundation.h"
        ^
/Applications/Xcode 8.1.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator3.1.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:9: note: in file included from /Applications/Xcode 8.1.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator3.1.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
#import <AVFoundation/AVAsset.h>
        ^
/Applications/Xcode 8.1.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator3.1.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAsset.h:16:9: error: 'CoreMedia/CMTime.h' file not found
#import <CoreMedia/CMTime.h>
        ^
/***********************************/ watch Extension/RGSpeechInterfaceController.swift:11:8: error: could not build Objective-C module 'AVFoundation'
import AVFoundation

Please report this against the 8.1 GM seed just to make sure it is being addressed. Thanks!

We wrote a script that patches up the watchSimulator to work around this:

https://gist.github.com/steipete/fc633fe4ac812f5c696c3db6554509a9


I reported this as rdar://29131674

https://openradar.appspot.com/29131674


This also fixes the issue that the CoreText framework is *completely* missing from the watchSimulator. rdar://27844864

https://openradar.appspot.com/27844864

Quick update - many duplicates of the these problems as one would imagine and the issues are actively being addressed. Any new reports will likely be returned as a dupe and closed at this point, so FYI.