Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.71] Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RTNCalculator' could not be found #35876

Closed
atar9500 opened this issue Jan 18, 2023 · 1 comment
Labels
Resolution: Answered When the issue is resolved with a simple answer Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@atar9500
Copy link

atar9500 commented Jan 18, 2023

Description

When following RN documentation to set up a turbo module to a new architecture project, I am receiving the following error:

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RTNCalculator' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

Screenshot 2023-01-18 at 14 54 58

However, in Xcode my module does appear under react-codegen

Screenshot 2023-01-18 at 15 10 47

Note:

I was able to generate with codegen using generate-codegen-artifacts.js instead of generate-artifacts.js, as it was not found in MyApp/node_modules/react-native/scripts/. Shouldn't it be updated in the documentation?

Version

0.71.0

Output of npx react-native info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 306.27 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.4.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.2.0 - /opt/homebrew/bin/npm
    Watchman: 2023.01.09.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 31, 33, 33
      Build Tools: 30.0.3, 33.0.0, 33.0.1
      System Images: android-31 | ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.0 => 0.71.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Create a New Architecture project follow these steps.
  2. Try to add a turbo module following these steps. In order for an error to appear, make sure NativeCalculator.ts would be:
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import {TurboModuleRegistry} from 'react-native';

export interface Spec extends TurboModule {
  add(a: number, b: number): Promise<number>;
}

export default TurboModuleRegistry.getEnforcing<Spec>(
  'RTNCalculator',
) as Spec | null;

Snack, code example, screenshot, or link to a repository

https://github.com/atar9500/NewArchitectureDemo

@atar9500 atar9500 added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jan 18, 2023
@atar9500
Copy link
Author

The reason I got that error was simply because I placed the podspec file inside the ios folder instead the RTNCalculator 🤦🏽‍♂️

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Triage 🔍 labels Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Answered When the issue is resolved with a simple answer Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

2 participants