Fix RNWorklets StableAPI.h File Not Found and RNReanimated Pod Install Error
Fix `[!] Unable to find a specification for RNWorklets depended upon by RNReanimated` and `'RNWorklets/StableAPI.h' file not found` errors in React Native iOS builds with Reanimated 4 and react-native-worklets.
On this page
While running `pod install` or building a React Native iOS project, you may encounter `[!] Unable to find a specification for RNWorklets depended upon by RNReanimated` or `'RNWorklets/StableAPI.h' file not found`. These errors usually appear after upgrading React Native, installing or updating React Native Reanimated, or moving from Reanimated 3.x to Reanimated 4.x. Although React Native code generation may complete successfully, CocoaPods can still fail because it cannot resolve the native Worklets dependency required by Reanimated 4.
The Error
You may also see a related Xcode build error after `pod install`. This usually means the `RNWorklets` pod was not installed correctly, the Worklets headers were not generated, or Xcode is still using stale build artifacts.
What Causes This Error
Reanimated 4 depends on the separate `react-native-worklets` package. During iOS pod installation, CocoaPods tries to resolve the `RNWorklets` pod. If `react-native-worklets` is missing, incompatible, corrupted, or not linked correctly, pod installation can fail before the iOS project builds. If pod installation succeeds but headers are stale or missing, Xcode may fail later with `StableAPI.h file not found`.
- `react-native-worklets` package is missing
- Reanimated and Worklets versions are incompatible
- Worklets Babel plugin is missing from `babel.config.js`
- Old `react-native-reanimated/plugin` is still used with Reanimated 4
- Corrupted `node_modules` directory
- Stale Pods or Podfile.lock files
- Incomplete dependency installation
- Upgrading React Native without upgrading Reanimated dependencies
- Mixing Reanimated 3.x and 4.x setup instructions
- Stale Xcode DerivedData caching old header paths
Fix 1: Check Installed Versions
Before changing dependencies, verify which Reanimated version is installed and whether `react-native-worklets` exists in your project.
Fix 2: Install React Native Worklets
If you are using Reanimated 4, install `react-native-worklets`. The Worklets version should be compatible with your installed Reanimated version.
Fix 3: Add the Worklets Babel Plugin
For Reanimated 4, make sure your `babel.config.js` uses the Worklets Babel plugin. If your config still uses `react-native-reanimated/plugin`, replace it with `react-native-worklets/plugin`. Keep the plugin last in the plugins array.
Fix 4: Delete Pods and Reinstall
Outdated pod metadata can prevent CocoaPods from resolving `RNWorklets` correctly. Delete Pods and regenerate the iOS dependencies from scratch.
Fix 5: Reinstall Node Modules
If JavaScript dependencies are corrupted or partially installed, removing `node_modules` and reinstalling packages can restore missing native references.
Fix 6: Clear Xcode DerivedData
If `pod install` succeeds but Xcode still shows `StableAPI.h file not found`, stale build artifacts in DerivedData may be pointing to old header paths. Clearing DerivedData forces Xcode to rebuild the iOS project with fresh native headers.
Fix 7: Verify Reanimated Compatibility
Different Reanimated versions have different setup requirements. Reanimated 4 requires `react-native-worklets`, while Reanimated 3 uses the older Reanimated setup. Avoid mixing Reanimated 3.x instructions with Reanimated 4.x dependencies.
Fix 8: Update CocoaPods Repository
Older local CocoaPods metadata can sometimes prevent pods from resolving correctly. Updating the pod repository ensures CocoaPods uses the latest available podspec information.
Fix 9: Reinstall React Native Reanimated
If Reanimated and Worklets versions are mismatched, reinstalling Reanimated and then reinstalling pods can resolve dependency conflicts.
Fix 10: Reset Metro Cache
After changing Reanimated, Worklets, or Babel configuration, reset the Metro cache. This helps prevent JavaScript from being transformed with an old plugin configuration.
Example Failure Log
Quick Diagnosis Checklist
- Verify the installed Reanimated version
- Check whether `react-native-worklets` is installed
- Install a compatible `react-native-worklets` version
- Use `react-native-worklets/plugin` in `babel.config.js` for Reanimated 4
- Keep the Worklets Babel plugin last in the plugins array
- Delete Pods and Podfile.lock
- Run `pod install --repo-update`
- Remove and reinstall node_modules
- Clear Xcode DerivedData if `StableAPI.h` error persists after pod install
- Ensure Reanimated and Worklets versions are compatible
- Update CocoaPods repository
- Reset Metro cache after changing Babel config
- Rebuild the app after successful pod installation
FAQ
Why does pod install fail with RNWorklets?
This usually happens when Reanimated 4 is installed but the separate `react-native-worklets` package is missing, incompatible, or not installed correctly.
What causes StableAPI.h file not found?
The `RNWorklets` pod is either missing, not installed correctly, or Xcode is using stale native header paths. Installing `react-native-worklets`, reinstalling pods, and clearing DerivedData usually fixes it.
Do I need react-native-worklets?
Yes, if you are using Reanimated 4. Reanimated 4 depends on the separate `react-native-worklets` package.
Should I use react-native-reanimated/plugin or react-native-worklets/plugin?
For Reanimated 4, use `react-native-worklets/plugin` in `babel.config.js`. If your project still has `react-native-reanimated/plugin`, replace it when using the Reanimated 4 setup.
Can deleting Pods solve this issue?
Yes. Removing Pods and Podfile.lock can fix stale CocoaPods metadata and allow CocoaPods to regenerate the native dependencies correctly.
Is this a React Navigation problem?
No. React Navigation may trigger the issue if it leads you to install or update Reanimated, but the root cause is Reanimated and its native Worklets dependency.
Why does code generation succeed but pod install fail?
React Native Codegen can complete before CocoaPods resolves all native dependencies. Pod installation can still fail later if CocoaPods cannot locate the `RNWorklets` pod.
Why does the error remain after installing react-native-worklets?
The installed Worklets version may be incompatible with Reanimated, pods may still be stale, or Xcode may be using old DerivedData. Check versions, reinstall pods, clear DerivedData, and reset Metro cache.
Shahmeer Rizwan
Full-Stack Developer