iosxcodereact-nativereact-native-vision-camera

iOS Build Fails with 'RNWorkletsSpec.h' file not found in Xcode (React Native 0.78 New Arch)


Problem

After upgrading to React Native 0.78 and enabling the New Architecture, my iOS build fails in Xcode with the following error: 
'RNWorkletsSpec.h' file not found This occurs when trying to build my app with react-native-worklets-core (used by VisionCamera for Frame Processors).

Environment

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

What I've Tried


Solution

  • Actually, this file should be automatically generated by React Native's Codegen system when New Architecture (RCT_NEW_ARCH_ENABLED=1) is enabled when the RNWorkletsSpec.h file is part of the TurboModule interface for the react-native-worklets-core library. If it's missing, it likely means the file hasn't been built or maybe the Xcode cannot find it.

    So add the following configuration to your package.json:

    "codegenConfig": {
      "name": "Worklets",
      "type": "modules",
      "jsSrcsDir": "src",
      "android": {
        "cmake": false
      }
    }
    

    Now clean and rebuild the Codegen, so run the lines one after the other:

    watchman watch-del-all
    rm -rf node_modules ios/Pods ios/build
    yarn install
    cd ios
    RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
    cd ..
    yarn react-native codegen
    

    After the above release you should find the header RNWorkletsSpec.h file in the following path:

    ios/build/generated/