facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.55k stars 24.37k forks source link

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 #38445

Closed qzyang closed 1 year ago

qzyang commented 1 year ago

Description

i use 0.72.3 with a exit ios app, build success , npm start success, but when in exiting ios app to load reactnative code ,it's show this error ,please hepl me fix this issue~

React Native Version

0.72.3

Output of npx react-native info

System: OS: macOS 13.4.1 CPU: (8) arm64 Apple M1 Memory: 177.72 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.3.1 path: /opt/homebrew/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 9.8.0 path: /opt/homebrew/bin/npm Watchman: version: 2023.07.03.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /Users/quzhenyang/.rvm/gems/ruby-2.7.5/bin/pod SDKs: iOS SDK: Platforms:

Steps to reproduce

use this podfile to reproduce

source 'https://github.com/CocoaPods/Specs.git'

Resolve react_native_pods.rb with node to allow for hoisting

require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', dir]).strip

platform :ios, min_ios_version_supported prepare_react_native_project!

install! 'cocoapods', :disable_input_output_paths => true

If you are using a react-native-flipper your iOS build will fail when NO_FLIPPER=1 is set.

because react-native-flipper depends on (FlipperKit,...) that will be excluded

#

To fix this you can also exclude react-native-flipper using a react-native.config.js

```js

module.exports = {

dependencies: {

...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),

```

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 'app' do

use_frameworks! :linkage => :static

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.

: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}/.."

)

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

pod 'RxSwift'
pod 'RxCocoa'
pod 'SDWebImage'
pod 'Alamofire'
pod 'MBProgressHUD'
pod 'SwiftyJSON'
pod 'SwiftyUserDefaults'
pod 'ObjectMapper'
pod 'Firebase/Crashlytics', '9.2.0'
pod 'Firebase/Analytics', '9.2.0'
pod 'Firebase/Messaging', '9.2.0'
pod 'SwipeCellKit'
pod 'Kingfisher'
pod 'WeScan'
pod 'RxDataSources', '~> 4.0'
pod 'ChameleonFramework'

pod 'FlexLayout'

pod 'SwiftSoup'
pod 'IQKeyboardManagerSwift'
pod 'GoogleMLKit/BarcodeScanning', '2.6.0'
pod 'MJRefresh'

target 'appTests' do inherit! :complete

Pods for testing

end

post_install do |installer|

https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202

react_native_post_install(
  installer,
  config[:reactNativePath],
  :mac_catalyst_enabled => false
)

__apply_Xcode_12_5_M1_post_install_workaround(installer) end end

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

use top podfile

github-actions[bot] commented 1 year ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide either:
garkuwa commented 1 year ago

the same issue here (RN 72.3), please help. Dev build works fine, but the release fails due to the aforementioned error

garkuwa commented 1 year ago

@qzyang I've sorted out the issues. In my case, while upgrading to RN 72.3, I've added .env.local with CONFIGURATION = Debug to my project Removing it from my CI/CD allowed RN to perform a Release build properly. Also, check your project.pbxproj, especially where you set your inputPaths with $(SRCROOT)/.xcode.env to ensure Debug and Release builds are configured properly. Hope this helps!

github-actions[bot] commented 1 year ago

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because the author hasn't provided the requested feedback after 7 days.

aloktiwari-eaton commented 1 year ago

still issue not resolved on "react-native": "0.70.13",

TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.

hitanshu-agsft commented 6 months ago

I am still facing this issue on "react-native": "0.72.4",

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

KingAmo commented 6 months ago

i am also face this issue TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found, in my case , i have import NativeDevSettings from 'react-native/Libraries/NativeModules/specs/NativeDevSettings'; in my js code, and after remove this related code , everything works fine

Johnsonzhangc commented 5 months ago

i am also face this issue TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found, in my case , i have import NativeDevSettings from 'react-native/Libraries/NativeModules/specs/NativeDevSettings'; in my js code, and after remove this related code , everything works fine

it works.

ghostgarrix commented 3 months ago

Having this issue in unit tests after bare RN project 0.75 upgrade. I never import DevSettings anywhere

mendozammatias commented 1 month ago

Having this issue when integrating React Native 0.75 in a brownfield application. React Native project is empty so I'm not importing DevSettings anywhere.

DardanIljazi commented 1 month ago

Just resolved this on my side ✅

In my case it was because I had 3 scheme: app, app_preprod and app_dev I had created different build configurations for each of them: Debug Release Debug-preprod Release-preprod Debug-dev Release-dev

Solved it by adding this on my Podfile:

# Replace 'app' with the name of your project
project 'app', {
  'Debug' => :debug,
  'Debug-dev' => :debug,
  'Debug-preprod' => :debug,
  'Release' => :release,
  'Release-dev' => :release,
  'Release-preprod' => :release,
}

And now it works