Skip to content

iOS crash: TextToSpeech.setDefaultRate(): Error converting JavaScript argument to Objective-C BOOL (unsupported type) #291

@jorgemengibar-jpg

Description

@jorgemengibar-jpg

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-tts version: (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
}
  1. Install react-native-tts
  2. Run the code above on iOS with New Architecture / Hermes enabled.
  3. Observe crash and error message.

Expected Behavior

  • setDefaultRate() and stop() 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 *)immediate

The 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 with NSNumber * or BOOL.
  • 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions