upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

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

Open feng-tianyou opened this issue 8 months ago • 1 comments

Environment

System: OS: macOS 14.6 CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz Memory: 53.99 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.20.6 - /var/folders/22/r_dvyr756hg6psq0qfbngv3r0000gn/T/yarn--1748403959387-0.20279640668029653/node Yarn: 1.22.22 - /var/folders/22/r_dvyr756hg6psq0qfbngv3r0000gn/T/yarn--1748403959387-0.20279640668029653/yarn npm: 10.8.2 - ~/.nvm/versions/node/v18.20.6/bin/npm Watchman: 2025.04.28.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.16.2 - /Users/tianyoufeng/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 24.0, iOS 18.0, macOS 15.0, tvOS 18.0, visionOS 2.0, watchOS 11.0 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8815526 Xcode: 16.0/16A242d - /usr/bin/xcodebuild Languages: Java: 1.8.0_202 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.14 => 0.71.14 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Things I’ve done to figure out my issue

Upgrading version

0.71.14

Description

package.json

{
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.71.14",
    "react-native-reanimated": "3.14.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.10",
    "patch-package": "^8.0.0",
    "postinstall-postinstall": "^2.1.0",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

app.json

{
  "name": "AwesomeProject",
  "displayName": "AwesomeProject"
}

index.js

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

Podfile

source 'https://cdn.cocoapods.org/'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'


flutter_application_path = '../../flutter_module/bk-flutter-app'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

platform :ios, '12.4'
prepare_react_native_project!
xcodeproj 'xxx.xcodeproj'

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end


target 'xxx' do
  
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
    install_all_flutter_pods(flutter_application_path)
    
    
      config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

    
end


post_install do |installer|
  flutter_post_install(installer) if defined?(flutter_post_install)
  
      react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  
  # 解决pod库签名问题
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGN_IDENTITY'] = ''
         end
    end
  end

end

iOS Project

NSURL *jsCodeLocation = [NSURL URLWithString:@"http://xx.xxx.11.1:8081/index.bundle?platform=ios"];
        
RCTRootView *rootView =
        [[RCTRootView alloc] initWithBundleURL: jsCodeLocation
                                    moduleName: @"AwesomeProject"
                             initialProperties:
         @{
            @"scores" : @[
                @{
                    @"name" : @"Alex",
                    @"value": @"42"
                },
                @{
                    @"name" : @"Joel",
                    @"value": @"10"
                }
            ]
        }
                                 launchOptions: nil];
UIViewController *vc = [[UIViewController alloc] init];
vc.view = rootView;
[self presentViewController:vc animated:YES completion:nil];

Run the project steps

npm install
cd ios & pod install
npx react-native start --reset-cache
。。。
Xcode: run

Error Info

[javascript] Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes
 [javascript] Running "AwesomeProject" with {"rootTag":1,"initialProps":{"scores":[{"name":"Alex","value":"42"},{"name":"Joel","value":"10"}]}}
[javascript] Invariant Violation: "AwesomeProject" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

Reproducible demo

feng-tianyou avatar May 28 '25 04:05 feng-tianyou

supplementary question attachment: Terminal: Image iPhone: Image

feng-tianyou avatar May 28 '25 06:05 feng-tianyou