naoufal / react-native-speech

A text-to-speech library for React Native.
https://www.npmjs.com/package/react-native-speech
304 stars 53 forks source link

[Bug] require('NativeModules').SpeechSynthesizer is undefined #1

Closed JonathanWi closed 8 years ago

JonathanWi commented 8 years ago

Hi,

Your plugin looks very promising, and I'd love to use it in my current project, but it seems that - since React core update (see https://github.com/facebook/react-native/issues/1821 ), SpeechSynthesizer is not part of the core anymore.

When trying to install your plugin, I'm prompted with an error screen due tu SpeechSynthesizer not being part of NativeModules.

Any Ideas on how to fix this?

Cheers

naoufal commented 8 years ago

Looks like it's just a matter of updating the require.

Could you submit a PR if you have time? Otherwise, I'll tackle this over the weekend.

JonathanWi commented 8 years ago

Hey thanks for the quick answer! I'm not sure how to update the require to be honest, would really appreciate if you have the time to do it!

Have a great week-end

aportner commented 8 years ago

I got this to work by following the instructions at: http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content

there's an xcode project for the speech module that you drag in and add to your linker

naoufal commented 8 years ago

@aportner is there anything you think I should add to the readme to make it more helpful?

aportner commented 8 years ago

nope, I think that's good. this was the first react native module I used, so I'm glad you included those instructions.

aportner commented 8 years ago

maybe move the "Linking the Library" part of the readme under Installation?

naoufal commented 8 years ago

Thanks for the feedback @aportner.

joshbuchea commented 8 years ago

I don't believe this issue was ever resolved. I am facing this same issue currently with React Native 0.14.2. The issue appears to be related to facebook/react-native#1821 like @JonathanWi stated initially.

I tried updating the require without success. It appears that NativeModules.SpeechSynthesizer does not evaluate to an object.

nicholasalanbrown commented 8 years ago

I'm having hte same problem @joshbuchea on 0.14.2.

nicholasalanbrown commented 8 years ago

Never mind, just got it working. This is the require update I had to make in SpeechSynethesizer.ios.js to get it to work:

var NativeSpeechSynthesizer = require('react-native').NativeModules.SpeechSynthesizer;
var invariant = require('react-native').invariant;

Note, this is not the same as the PR submitted by Yonas which reads like this:

var NativeSpeechSynthesizer = require('react-native').NativeModules;
// var invariant = require('invariant');
var invariant = require('react-native').invariant;
aladante commented 8 years ago

Hey, still new to coding but got kind of the same problem as above. but updating the require in SpeechSynethesizer.ios.js didn't work for me. got the error

undefined is not an object('evaluating NativeSpeechSynthesizer .stopSpeakingAtBoundary')

any ideas ?

cheers

allenmanning commented 8 years ago

Did you rebuild your ios project in xcode?

ksrawat commented 7 years ago

link the xcodeproj and re-run the app.. should work fine.. It works fine for me.