-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Description
Summary
On iOS, calling both Tts.setDefaultRate() and Tts.stop() causes crashes with the following errors:
setDefaultRate:
TextToSpeech.setDefaultRate(): Error while converting JavaScript argument 1
to Objective C type BOOL. Objective C type BOOL is unsupported.
stop:
TextToSpeech.stop(): Error while converting JavaScript argument 0
to Objective C type BOOL. Objective C type BOOL is unsupported.
Platform
- Platform: iOS
react-native-ttsversion: (your version here)- React Native version: (your version here)
- JS engine: Hermes
- Architecture: New Architecture enabled
- Device: (device + iOS version here)
- Build types: Debug and Release (TestFlight)
Steps to Reproduce
Minimal example:
import Tts from "react-native-tts";
import { Platform } from "react-native";
async function testTTS() {
await Tts.getInitStatus();
// Crashes on iOS:
await Tts.setDefaultRate(0.5);
// Later in the code:
await Tts.speak("Test TTS");
await Tts.stop(); // also crashes on iOS
}- Install
react-native-tts - Run the code above on iOS with New Architecture / Hermes enabled.
- Observe crash and error message.
Expected Behavior
setDefaultRate()andstop()should work on iOS or at least fail gracefully without crashing.
Actual Behavior
- The app crashes at the bridge layer when converting the JS arguments to Objective-C
BOOL. - In the iOS implementation, the native signatures use pointer types like:
skipTransform:(BOOL *)skipTransform
// and for stop(...)
stop:(BOOL *)immediateThe new iOS bridge / TurboModule type system does not support BOOL * and throws the “Objective C type BOOL is unsupported” error.
Additional context
- Other libraries have hit the same issue with
BOOL/BOOL *arguments when enabling New Architecture and Hermes. - This seems to affect any method in this module that uses
BOOL *parameters.
Temporary workaround
In JS, skipping these calls on iOS works around the crash:
if (Platform.OS === "android") {
Tts.setDefaultRate(0.5);
Tts.stop();
}Android continues to work fine; the problem is only on iOS.
Suggested fix
Update the iOS native module to avoid BOOL * in exported methods, e.g.:
- Replace
BOOL *parameters withNSNumber *orBOOL. - Handle the value inside the method (e.g.
immediate.boolValue).
Happy to test any patch or PR that removes the BOOL * usage and confirm it works with New Architecture + Hermes.
Metadata
Metadata
Assignees
Labels
No labels