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

'DevSettings' could not be found. Verify that a module by this name is registered in the native binary. #26987

Closed
mykhailo-melnyk opened this issue Oct 24, 2019 · 46 comments
Labels
API: Settings Bug Resolution: Locked This issue was locked by the bot.

Comments

@mykhailo-melnyk
Copy link

mykhailo-melnyk commented Oct 24, 2019

I tried to add new schemas to ios project. I added Staging-Debug copied from default Debug schema. When application is loading I catch the next error:

2019-10-24 15:43:05.427 [error][tid:com.facebook.react.JavaScript] Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.
2019-10-24 15:43:05.430 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.
2019-10-24 15:43:05.433396+0300 HelloGuest[3076:1701296] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the na..., stack:
getEnforcing@4947:28
<unknown>@41941:50
loadModuleImplementation@271:14
<unknown>@41900:40
loadModuleImplementation@271:14
<unknown>@36481:18
loadModuleImplementation@271:14
<unknown>@29159:16
loadModuleImplementation@271:14
guardedLoadModule@163:47
global code@375133:4

React Native version:

System:
OS: macOS 10.15
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 110.47 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 23, 24, 26, 27, 28
Build Tools: 23.0.1, 27.0.3, 28.0.2, 28.0.3
System Images: android-24 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7

Why can it happen?

@anhkieet
Copy link

I have the same issue with you :(

@matthiasthomas
Copy link

Same here!

2 similar comments
@maullerz
Copy link

Same here!

@maxperry
Copy link

Same here!

@maullerz
Copy link

In my case, i got this error only when trying to run debug build on device.
If i try to run on simulator - i am getting "No Bundle URL Present."
It is not connect to development server for js bundle.
After debugging finally realized that RCT_DEV not setted for debug builds in my new schema.

After some workaround like adding RCT_DEV=1 in Preprocessor flags,
started to get only error "TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found."
in simulator also.

@maullerz
Copy link

maullerz commented Oct 29, 2019

Workaround for me

  1. renamed back my "DEMO Debug" config to "Debug"
  2. changed my schemes accordingly
  3. also fixed "React(missing)" in Build part of schemes.

Снимок экрана 2019-10-29 в 12 31 00
(Delete the React (missing), click on the + on the bottom left, add React (from pods section). Finally, check all the checkboxes and place React at the top of the list.)

Now debug build working as expected, but i cant use different configs for different schemas, only 1 "Debug".

@mykhailo-melnyk
Copy link
Author

@maullerz yes, you are right but I want to use a different configuration for different schema
=(

@Jonovono
Copy link

Jonovono commented Oct 29, 2019

Getting this too, any ideas?

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

It's fine for me on dev with Debug config but using our Staging configuration, app builds but then crashes and I see this :(

@matthiasthomas
Copy link

Getting this too, any ideas? ...

@Jonovono so in my case I was actually only getting this on the Staging scheme, Local and Prod worked fine.
The issue was that debug was on for Staging, even though it’s supposed to behave like a release build. Now that I build Staging release it works fine.

Sent with GitHawk

@corneelius
Copy link

Make sure your bundle command includes --dev false if you're building for release

For example:
react-native bundle --entry-file index.js --dev false --reset-cache --bundle-output main.jsbundle

@mykhailo-melnyk
Copy link
Author

@corneelius where can I find these settings if I run project using Xcode?

@corneelius
Copy link

In Build Phases, there is a phase called Bundle React Native Code and Images. That runs a script that creates the bundle for release builds. It fails for me most of the time. I commented it out and created the bundle manually by running this:

react-native bundle --entry-file index.js --dev false --reset-cache --bundle-output main.jsbundle

After that, drag the bundle into the Xcode project and try running again in release mode.

@mykhailo-melnyk
Copy link
Author

any updates on this?

@takameyer
Copy link

takameyer commented Nov 8, 2019

I was able to solve this in my Podfile

target 'MyApp' do
  project 'MyApp',
  'Staging-Debug' => :debug,
  'Staging-Release' => :release,
  ...

This ensures that your build configuration is marked as "debug" or "release" in the underlying Pod xcode projects (including react-native).

Reference:
https://guides.cocoapods.org/syntax/podfile.html#project

@arbielsk
Copy link

arbielsk commented Nov 8, 2019

@takameyer Thank you for your solution, this works perfectly for my version of the issue!

For anyone with a similar issue to mine, this might be helpful:
I've been on this issue way too long updating from 0.59 -> 0.61.4 and switching from manually linked packages to using cocoapods.

In my case the issue already presented it before this with 'No bundle url present' because preprocessing-variable RCT_DEV was automatically set to 0. Only after finding a workaround for that issue (setting the jsBundleLocation in AppDelegate.m to a hardcoded value in case it was nil) I got the issue seen above.

We are using react-native-schemes-manager which previously solved this issue automagically.

@mykhailo-melnyk
Copy link
Author

mykhailo-melnyk commented Nov 8, 2019

@takameyer

  1. Could you please show full pod file?
  2. What does this sentence mean?
    "This ensures that your build configuration is marked as "debug" or "release" in the underlying Pod xcode projects (including react-native)."
  3. Should we do some "pod install" after changed pod file?

@takameyer
Copy link

@mykhailo-melnyk

  1. No Problem:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'MyApp' do
  project 'MyApp', 
  'Staging-Debug' => :debug,
  'Staging-Release' => :release,

  # Pods for HBAPP
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  use_native_modules!

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-config'
      phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
       phase.shell_script = "cd ../../"\
        " && RNC_ROOT=./node_modules/react-native-config/"\
        " && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
        " && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
 
       target.build_phases << phase
       target.build_phases.move(phase,0)
    end
  end
end
  1. I was previously using react-native-scheme-manager to do this in older version of RN. What this did was go through every xcodeproj file that existed in node_modules and wrote all my projects build configurations in them (at least that is my rough understanding).
    What the Podfile does is quite similar, except it does no rewriting. It basically says take the build configuration "Staging-Debug" and handle it as if it were the build configuration "debug" in all the Pod dependencies. That is also only my rough understanding of how it works.

  2. Yes. I would recommend a complete reinstall of everything:

> rm -rf node_modules
> yarn
> cd ios
> pod install

Another caveat, if you, like me, are coming from using 'react-native-scheme-manager", uninstall this completely using the instructions from https://github.com/thekevinbrown/react-native-schemes-manager#uninstalling
In my case this was no longer necessary to have and only caused more problems migrating from RN 59 -> 61

@mykhailo-melnyk
Copy link
Author

@takameyer
thanks a lot!
it really helped in my case ( I also removed using react-native-scheme-manager)

@luskin
Copy link

luskin commented Nov 16, 2019

Unfortunately we are still receiving this error. We are building a fresh app on 0.61.4.

Error:

[fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.
libc++abi.dylib: terminating with uncaught exception of type NSException

Podfile:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'MyApp' do
  # Custom Configs
  project 'MyApp',
  'Debug (Staging)' => :debug,
  'Debug (Production)' => :debug,
  'Release (Staging)' => :release,
  'Release (Production)' => :release
  
  # Pods for MyApp
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  
  # Firebase
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
  pod 'RNFBDatabase', :path => '../node_modules/@react-native-firebase/database'
  pod 'RNFBAuth', :path => '../node_modules/@react-native-firebase/auth'
  
  pod 'ReactNativeNavigation', :podspec => '../node_modules/react-native-navigation/ReactNativeNavigation.podspec'
  
  pod 'react-native-intercom', :path => '../node_modules/react-native-intercom'
  
  ## PERMISSIONS
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"

  use_native_modules!
end

We have done several full removals and reinstalls of the pods including the lockfile. Not sure where to go from here, any help would be greatly appreciated.

@takameyer
Copy link

takameyer commented Nov 18, 2019

@luskin How were your build configurations generated? Have you tried making a new one by duplicating 'Debug' and 'Release' from the Project -> Info tab?
image
I would attempt this again and try and build only with that configuration. If that works then generate the rest in the same manner.

Also I would double check the Scheme to make sure the correct build configuration is selected for the Run step.

@luskin
Copy link

luskin commented Nov 18, 2019

@takameyer Yes, this is how I created the additional configurations. I duplicated Debug and Release to create the new Staging and Production debug and release configurations.

UPDATE: I have actually removed all other build configurations and reverted back to the default Debug and Release configs and we are still receiving the error: 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary. after any codepush update restart.

Our issue is related to this issue: microsoft/react-native-code-push#1704

UPDATE: Downgrading react-native to 0.60.5 fixed our issues.

@RSNara
Copy link
Contributor

RSNara commented Nov 20, 2019

This error occurs because the native implementation of ExceptionsManager wasn't found. As I make these NativeModules TurboModule-compatible, anything that lies in the following paths will be moved to CoreModules:

[
    "React/Base/**/*.m",
    "React/Base/**/*.mm",
    "React/DevSupport/**/*.m",
    "React/DevSupport/**/*.mm",
    "React/Inspector/**/*.m",
    "React/Inspector/**/*.mm",
    "React/Modules/**/*.m",
    "React/Modules/**/*.mm",
    "React/Profiler/**/*.m",
    "React/Profiler/**/*.mm",
    "React/Profiler/**/*.S",
    "React/UIUtils/*.m",
    "React/Views/**/*.m",
    "React/Views/**/*.mm",
    "Libraries/ActionSheetIOS/*.m",
    "Libraries/WebSocket/*.m",
]

To anyone who has this problem, does depending on the React-CoreModules pod fix the problems?

@luskin
Copy link

luskin commented Nov 20, 2019

@RSNara to confirm, you are recommending updating the Podfile to include:

pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'

If so I will re-update the app to RN 0.61.4, include this pod and report back

UPDATE: It turns out that the React-CoreModule pod dependency is already included in 0.61.4 (see here) - I will attempt this again but we attempted this before on a fresh installation of 0.61.4 so I'm not hopeful.

@ahartzog
Copy link

@luskin @RSNara I've had the React-CoreModule in my pod since September 18th, both before and after experiencing this issue.
image

@treyp
Copy link

treyp commented Nov 21, 2019

I had this problem, but turns out I wasn't using the correct build configuration name.

If you're working on a brownfield app like me, here's where you can see the exact build configuration names in the scheme editor:

Screen Shot 2019-11-20 at 12 01 06 PM

Make sure they match up exactly in your podfile:

Screen Shot 2019-11-20 at 12 03 01 PM

After getting those to match, everything started working on RN 0.61.4.

@luskin
Copy link

luskin commented Nov 21, 2019

@treyp - We reverted any custom schemes and are back to the classic Debug/Release schemes, so this doesn't apply to us.

@RSNara - We upgraded back up to 0.61.4 from 0.60.5 to re-attempt your proposed solution but it does not work. We are still receiving the error.

@ahartzog
Copy link

Removing the --development flag from my codepush release build process resolved this error for me.

@luskin
Copy link

luskin commented Nov 24, 2019

@ahartzog You seemed to have solved the issue! We were using the --dev flag to deploy to our staging environment but removing that and setting the destination like you advised solved the issue. THANK YOU!

@ahartzog
Copy link

Awesome, glad to hear that. I'd write a PR to update the docs that this is an issue with 0.61+ but...it wouldn't get merged so...

@kmvkrish
Copy link

kmvkrish commented Dec 4, 2019

You can follow this link for a clear explanation: Multiple schemes in RN apps

@nihp
Copy link

nihp commented Jan 13, 2020

@takameyer I am getting the same error. How can I resolve this? I tried the following

react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle --assets-dest ios

But it not worked for me. Again I am getting

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

@nihp
Copy link

nihp commented Jan 13, 2020

ahartzog Where i need to remove the development flag. Is it mandatory to add the custom config scheas in podfile

@nihp
Copy link

nihp commented Feb 6, 2020

The above is fixed for me after changing the node -v as before.

I have used node -v 9.4.0 and again changed to 12.0. So I got above error.

To resolve this I have moved to the old one 9.4.0 and it get solved

@alpeshgaglani
Copy link

Any updates on this issue? It's preventing us from using RN in our existing app - Bundling and accessing it as an asset works, but it's hurting productivity big time because we can load from local metro bundler service, or do any debugging.

@ivanushka1703
Copy link

I was able to solve this problem, move custom configurations in Podfile above target section.
image

@cbedoy
Copy link

cbedoy commented Aug 4, 2020

I'm not using custom configurations, we only have Debug|Release schemas.

I've been trying with 0.62.2, and 0.63.2, but still having instant crash when run on release mode or when testers got new build from testflight.

2020-08-04 10:14:38.514908-0500 RNCliDagM8[67965:1042593] [] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2020-08-04 10:14:38.515 [error][tid:com.facebook.react.JavaScript] Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.
2020-08-04 10:14:38.516991-0500 RNCliDagM8[67965:1042593] [] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2020-08-04 10:14:38.518256-0500 RNCliDagM8[67965:1042584] [] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2020-08-04 10:14:38.518556-0500 RNCliDagM8[67965:1042584] TCP Conn 0x600003a84e40 Failed : error 0:61 [61]
2020-08-04 10:14:38.519 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.
2020-08-04 10:14:38.552387-0500 RNCliDagM8[67965:1042593] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the na..., stack:```

@sameid
Copy link

sameid commented Sep 27, 2020

I've been experiencing the same issue since I updated to Xcode 12.

Here is my react-native info output:

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 4.21 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
    Yarn: Not Found
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.0, 28.0.2, 28.0.3, 29.0.3
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 12.0/12A7209 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_251 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Here is what happens when I try to run the scheme in Release mode.

libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the na..., stack:
invariant@4555:25
getEnforcing@4826:27
<unknown>@35255:49
loadModuleImplementation@271:13
<unknown>@35165:61
loadModuleImplementation@271:13
<unknown>@34910:31
loadModuleImplementation@271:13
<unknown>@35943:35
loadModuleImplementation@271:13
<unknown>@27866:15
loadModuleImplementation@271:13
guardedLoadModule@163:46
global code@180966:3
'
terminating with uncaught exception of type NSException
(lldb) 

Important note is that I am able to run my build in Debug mode.

Update: I simply downloaded Xcode 11.6 and my release build continued to work.

@dehypnosis
Copy link

dehypnosis commented Oct 5, 2020

@sameid didnt work for me..
Been 1y since this error first seen and still don't have clear solution?

@dehypnosis
Copy link

dehypnosis commented Oct 7, 2020

A workaround.

  1. Comment iOS invariant assertion in NativeEventEmitter.js
diff --git a/node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js b/node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js
index 59e03aa..1a6bdbf 100644
--- a/node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js
+++ b/node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js
@@ -34,7 +34,9 @@ class NativeEventEmitter extends EventEmitter {
   constructor(nativeModule: ?NativeModule) {
     super(RCTDeviceEventEmitter.sharedSubscriber);
     if (Platform.OS === 'ios') {
-      invariant(nativeModule, 'Native module cannot be null.');
+      // COMMENTED AS PATCH: .... hell noway to fix DevSettings bug
+      // ref: https://github.com/facebook/react-native/issues/26987
+      // invariant(nativeModule, 'Native module cannot be null.');
       this._nativeModule = nativeModule;
     }
   }
  1. in iOS Pods project Build Settings, Set Processor Macros for Release as like
...
RCT_DEBUG=0
RCT_DEV=0
RCT_DEV_MENU=1
ENABLE_PACKAGER_CONNECTION=0

Hmm... It works for now.
My current env:

$ react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.15.6
    CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
    Memory: 982.60 MB / 40.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.2 - /usr/local/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0. - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 26, 27, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      System Images: android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 Canary 11 4.2 Canary 11
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.5 - /Users/dw.kim/.sdkman/candidates/java/current/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: ^0.63.3 => 0.63.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found (It is )

@jamesjara
Copy link

Hello, this error took me a lot of time as well :(
so let me share the my solution, the problem is with the node_modules/react-native/scripts/react-native-xcode.sh for some reason is passing --dev true even in the release configurations. So i did a patched copy of the react-native-xcode.sh and copy it in the postintall script"

"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
  $CONFIG_ARG \
  --entry-file "$ENTRY_FILE" \
  --platform ios \
  --dev false \. // pass as false dev
  --reset-cache \
  --bundle-output "$BUNDLE_FILE" \
  --assets-dest "$DEST" \
  $EXTRA_PACKAGER_ARGS

@evanjmg
Copy link

evanjmg commented May 26, 2021

This issue can be closed since it's podfile configuration - might want to add this to setup instructions

@elsurudo
Copy link
Contributor

This is still an issue, and I don't think it's just podfile configuration.

In my case, I can see in my build output that the command being run is correct (e.g. --dev false). Despite this, I am still getting the same error. Does anyone have any idea what else to try here? I tried pretty much all the applicable solutions in this thread to no avail...

@elsurudo
Copy link
Contributor

Well, I feel pretty dumb, but in my case it ended up being that I was using DevSettings in my index.js file, so I needed to make sure that code only ran in dev, like so:

if (Config.ENV == 'development') {
  ...
}

@Celleb
Copy link

Celleb commented Jul 25, 2021

This is just a workaround that might provide some relief. This worked on RN v0.62 but not RN v0.64

Do this only when building for none dev

Find this file node_modules/react-native/Libraries/Utilities/DevSettings.js

comment out this line or delete this line import NativeDevSettings from '../NativeModules/specs/NativeDevSettings';

comment out or delete this class:

class DevSettings extends NativeEventEmitter implements IDevSettings {
  _menuItems: Map<string, () => mixed>;

  constructor() {
    super(NativeDevSettings);

    this._menuItems = new Map();
  }

  addMenuItem(title: string, handler: () => mixed) {
    // Make sure items are not added multiple times. This can
    // happen when hot reloading the module that registers the
    // menu items. The title is used as the id which means we
    // don't support multiple items with the same name.
    const oldHandler = this._menuItems.get(title);
    if (oldHandler != null) {
      this.removeListener('didPressMenuItem', oldHandler);
    } else {
      NativeDevSettings.addMenuItem(title);
    }

    this._menuItems.set(title, handler);
    this.addListener('didPressMenuItem', event => {
      if (event.title === title) {
        handler();
      }
    });
  }

  reload(reason?: string) {
    if (typeof NativeDevSettings.reloadWithReason === 'function') {
      NativeDevSettings.reloadWithReason(reason ?? 'Uncategorized from JS');
    } else {
      NativeDevSettings.reload();
    }
  }

  onFastRefresh() {
    if (typeof NativeDevSettings.onFastRefresh === 'function') {
      NativeDevSettings.onFastRefresh();
    }
  }

  // TODO: Add other dev setting methods exposed by the native module.
}

modify this line

module.exports = ((__DEV__
  ? new DevSettings()
  : new NoopDevSettings()): IDevSettings);

To

module.exports = (new NoopDevSettings(): IDevSettings);

@LordMendes
Copy link

In my specific situation, I was using a deprecated version of expo/ex-navigation , in RN 0.64.2 we had one problem, because RN doesn't understood the @2x.android or similars casts to choose the right image for an Icon. The problem is Described here : #31348.

I sold my conflicts locally inside node_modules and make Android work fine (then I forked and create a correction under my control), but when I came back to work in my IoS problems, I forgot to use this correction.

So, my problem was occurring in one lib i had in my node_modules, and as I extensively searched, this problems use to happen in this kind of situation.

So if @takameyer solution doesn't work as it doesn't to me, I suggest taker a look in your node_modules dependencies...

probably trying to build your bundle thought react-native-cli will give you an better log then building this in xcode, since in my case xcode build worked but give-me a run-time error(Release).

I hope it help some one in the future.

@safaiyeh
Copy link
Contributor

safaiyeh commented Aug 2, 2021

Appreciate all the discussion in this issue. Closing as there are multiple workarounds and ways to resolve this in the thread.

@safaiyeh safaiyeh closed this as completed Aug 2, 2021
@facebook facebook locked as resolved and limited conversation to collaborators Aug 2, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Settings Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests