You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native 0.78新架构下Xcode编译报错:RNWorkletsSpec.h文件未找到

React Native 0.78新架构iOS编译报错:RNWorkletsSpec.h 文件未找到

问题描述

升级至React Native 0.78并启用新架构后,iOS应用在Xcode中编译失败,报错信息为:'RNWorkletsSpec.h' file not found。该问题发生在使用react-native-worklets-core(VisionCamera帧处理器依赖库)的项目编译过程中。

环境信息

{
  "react-native": "0.78.0",
  "react-native-worklets-core": "1.5.0",
  "react-native-vision-camera": "4.6.3",
  "react": "19.0.0"
}

已尝试方案

  • 清理编译并重新安装:执行命令 rm -rf node_modules ios/Pods ios/build && yarn install,再执行 cd ios && pod install
  • 手动运行Codegen:执行命令 yarn react-native codegen
  • 启用新架构执行pod install:RCT_NEW_ARCH_ENABLED=1 pod install

解决方案

1. 升级依赖适配新架构

react-native-worklets-core 1.5.0对RN 0.78新架构的支持存在兼容性问题,优先升级到最新稳定版:

yarn add react-native-worklets-core@latest

同时确认react-native-vision-camera版本适配性,必要时同步升级:

yarn add react-native-vision-camera@latest

2. 修正Xcode头文件搜索路径

打开Xcode项目,进入Build Settings,找到Header Search Paths,添加以下路径并设置为recursive:

$(PROJECT_DIR)/../node_modules/react-native-worklets-core/build/generated/ios

3. 执行新架构下的完整清理构建流程

彻底清理缓存后严格按新架构步骤重新执行:

# 清理所有缓存
rm -rf node_modules ios/Pods ios/build ~/Library/Caches/CocoaPods
yarn cache clean

# 重新安装依赖
yarn install

# 启用新架构并更新pod仓库后安装
cd ios
RCT_NEW_ARCH_ENABLED=1 pod install --repo-update

# 重新运行Codegen
cd ..
yarn react-native codegen

4. 检查并添加Codegen生成文件

在Xcode中选中主Target,进入Build Phases → Compile Sources,确认是否包含RNWorkletsSpec.mm文件。若缺失,手动添加该文件(路径一般为ios/Pods/Target Support Files/RNWorkletsCore/RNWorkletsSpec.mm)


内容的提问来源于stack exchange,提问作者themaster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 22:25:06