Question

I'm trying to use my code to be compatible for both iOS 6 & 7, using the synthesized speech. I wanna it to be available for iOS 7 and not available for iOS 6.

The problem is when I run in the simulator in iOS 6 it gives following error even before the simulator get to start: dyld: Symbol not found: _AVSpeechUtteranceMaximumSpeechRate .

If I comment the line: utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f; works great for iOS 6 to start even if its not designed for it.

What be the issue?

Thanks.

 if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
            // Load resources for iOS 7 or later
            AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
            AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:selectedText];
            utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;
            utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // defaults to your system language
            [synthesizer speakUtterance:utterance];
            [synthesizer release];
        }
        else{
            // Load resources for iOS 6 or earlier
            UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Sorry"
                                                             message:@"This feature requires iOS 7.0 or later"
                                                            delegate:Nil
                                                   cancelButtonTitle:@"OK"
                                                   otherButtonTitles: nil] autorelease];
            [alert show];

        }
Was it helpful?

Solution

Just add this line at the top of your file:

AVF_EXPORT const float AVSpeechUtteranceMaximumSpeechRate NS_AVAILABLE_IOS(7_0);

With a weakly imported symbol, dyld will not crash if it doesn’t find the symbol when your app starts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top