I’m excited to share a set of mobile apps I’ve recently completed and published on both the Google Play Store and the Apple App Store. These apps are designed with a simple goal in mind: to make meaningful, structured content more accessible, whether you’re studying theology or improving your English vocabulary. 📱 Now Available on Both Platforms All apps are live and available for download: Google Play Developer Page: https://play.google.com/store/apps/dev?id=5835943159853189043 Apple App Store Developer Page: https://apps.apple.com/ca/developer/q-z-l-corp/id1888794100 📖 Theology & Confession Study Apps For those interested in Reformed theology and classical Christian teachings, I’ve developed a series of apps that present foundational texts in a clean, focused reading format: The Belgic Confession Canons of Dort Heidelberg Catechism Westminster Shorter Catechism Each app is designed to provide a distraction-free experience, making it easier to read, reflect, and revisit these im...
React Native TTS iOS 问题全解析:修复 BOOL 错误与事件监听失效(2026 实战指南)
- Get link
- X
- Other Apps
By
Errong Leng
-
React Native TTS iOS 问题全解析:修复 BOOL 错误与事件监听失效(2026 实战指南)
在 React Native 中使用文本转语音(TTS)本来很简单,但在 iOS 上却可能踩坑。
本文总结了两个非常常见但又很隐蔽的问题,并提供经过验证的解决方案。
🧨 问题一:Objective-C type BOOL is unsupported
错误信息
TextToSpeech.setDefaultRate(): Error while converting JavaScript argument to Objective C type BOOL
convert javascript argument to object C type Bool object C type bool is unsupported
🔍 根本原因
这不是你的代码问题。
这是由于 iOS 原生桥接层(Objective-C)类型定义错误导致的,尤其在 React Native 新架构(Fabric / TurboModules)下更容易触发。
部分版本的 react-native-tts 错误地使用了:
(BOOL *)onWordBoundary ❌ 错误
而 React Native bridge 不支持 BOOL 指针类型,只支持:
- BOOL
- NSNumber *
✅ 解决方案
使用已修复的 fork 版本:
@iternio/react-native-tts
npm install @iternio/react-native-tts
该版本已修复 iOS 类型问题,可以正常运行。
⚠️ 问题二:事件监听器未注册
警告信息
Sending `tts-start` with no listeners registered.
即使你已经写了监听:
Tts.addEventListener('tts-start', () => {
setIsSpeaking(true);
});
🔍 根本原因
问题在于:TTS 模块尚未初始化完成,你就注册了监听器。
- Native 层事件已触发 ✅
- JS 监听器尚未就绪 ❌
✅ 关键修复(必须做)
在使用 TTS 前,必须等待初始化:
useEffect(() => {
const init = async () => {
await Tts.getInitStatus(); // 👈 非常关键
Tts.setDefaultRate(0.5);
Tts.setDefaultPitch(1.0);
const sub = Tts.addEventListener('tts-start', () => {
setIsSpeaking(true);
});
return () => sub.remove();
};
init();
}, []);
💡 总结
- react-native-tts 在 iOS 上存在已知问题
- BOOL 错误属于 Native 层 bug,不是 JS 写法问题
- 必须调用
Tts.getInitStatus()再使用
🚀 推荐实践
- ✅ 使用
@iternio/react-native-tts - ✅ 所有调用前等待初始化
- ⚠️ 新架构(Fabric)下需特别注意兼容性
🧩 进阶建议
如果你在开发生产级应用,建议直接封装 iOS 原生 TTS:
- 使用 AVSpeechSynthesizer
- 自定义 React Native bridge
这样可以彻底避免第三方库带来的不稳定问题。
✍️ 结语
这些问题非常隐蔽,但其实很常见。如果你也遇到类似问题,希望这篇文章能帮你节省大量排查时间。
Happy coding 🚀
❤️ Support This Blog
If this post helped you, you can support my writing with a small donation. Thank you for reading.
- Get link
- X
- Other Apps
Popular Posts
2026 Begins: Choosing to Stay on the Path as a Blogger
By
Errong Leng
-
Today is January 1st, 2026 . Before rushing into new goals, I spent some time looking back at the past 12 months of data for this blog — the quiet numbers that tell a very honest story. Looking Back at the Numbers Over the past year: 📈 Total views: ~44,600 👀 Daily average visits: ~200 💬 Comments: 19 💰 AdSense income: about $0.01 per month At first glance, these numbers may look small — especially the income. But when I zoom out, I see something more meaningful. This blog has been quietly read every single day . No viral posts. No aggressive promotion. No paid traffic. Just consistent readers arriving through search, bookmarks, and curiosity. That consistency matters. What the Traffic Graph Tells Me The graph over the last 12 months shows something important: Early months were quiet and uneven Mid-year brought steady growth Toward the end of the year, traffic became more stable , with clear spikes when certain posts resonated This tell...
Cross compile tensorflow for armv7l targets via bazel
By
三好Daddy
-
Health Checks and Scaling Strategies for Next.js in Kubernetes
By
Errong Leng
-
Health Checks and Scaling Strategies for Next.js in Kubernetes This is Part 6 and the final post of the series: Self-Hosting Next.js in Kubernetes (Without Vercel) . At this point, your Next.js standalone app: Builds cleanly Runs in a minimal Docker image Deploys correctly on Kubernetes / OpenShift Serves static assets properly Uses runtime configuration and secrets Now let’s make it resilient and scalable . Why Health Checks Matter Kubernetes relies on health checks to: Know when a pod is ready to receive traffic Restart unhealthy containers Safely roll out new versions Without proper probes, traffic can be sent to a pod that isn’t ready yet. Readiness Probe A readiness probe tells Kubernetes: “This pod can accept traffic.” For most Next.js apps, the root path works well: readinessProbe: httpGet: path: / port: 3000 initialDelaySeconds: 10 periodSeconds: 5 If your app depends on downstream services (APIs, d...
Comments
Post a Comment