【问题标题】:Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found不变违规:TurboModuleRegistry.getEnforcing(...): 'DevSettings' 找不到
【发布时间】:2020-04-29 23:31:55
【问题描述】:

应用程序因上述消息而崩溃。无法查看我的应用屏幕。

不变违规:TurboModuleRegistry.getEnforcing(...): 'DevSettings' 找不到。验证此名称的模块是否已在名称...,堆栈中注册:

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

target 'App' do
  # Pods for App
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  #pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
  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 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

  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'

  pod 'react-native-cameraroll', :path => '../node_modules/@react-native-community/cameraroll'

  target 'AppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

target 'App-tvOS' do
  # Pods for App-tvOS

  target 'App-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

【问题讨论】:

  • 你用什么方案来构建 xcode?由于使用自定义构建(如 staging-debug 和 release-debug)的 Podfile 不正确,我过去曾遇到过这个问题。你能发布你的 Podfile 吗?
  • 确实,我也遇到了同样的问题。我的问题正如@AndrewMeyer 所说,我的 podfile 项目方案映射的命名与实际方案名称不同。更换它们,清洁吊舱,安装和建造工作。谢谢
  • 我已经在我的 Xcode 方案中进行了发布和调试。现在突然我得到了 main.jsbundle not found 的错误,所以我运行了一个 react-native bundle 命令。但它显示了上面的消息。
  • 自定义配置是不是好办法
  • @AndrewMeyer 更新了我上面的 podfile

标签: react-native react-native-ios


【解决方案1】:

我遇到了同样的错误,问题是我在 Release 模式下构建了应用程序,但 main.jsbundledev 模式。

使用react-native@0.61.5

我停止了 Metro 进程并再次运行

react-native run-ios --configuration Release --device --scheme="MyTargetScheme"

【讨论】:

【解决方案2】:

对我们来说,问题是我们(手动)为我们的生产应用程序构建 RN 包,而没有在 react-native CLI 中设置 dev 值。

在 Xcode 中使用调试配置在模拟器或设备上进行测试时,这不是问题。但由于我们使用发布配置为 App Store 存档,因此我们在生产中看到了这种崩溃。

react-native bundle 命令的 --dev 开关默认设置为 true。所以解决方法就是在 bundle 命令中添加--dev false

【讨论】:

    【解决方案3】:

    就我而言,我的问题已通过 node -v 更改解决。

    最初我使用节点 9.4.0,然后我将节点更改为 12。

    Due to this version change the above error occurs.
    

    所以我已更改为节点 9.4.0 并在发布模式下重建应用程序。效果很好

    任何人都知道为什么节点版本更改无法在发布模式下捆绑应用

    【讨论】:

      【解决方案4】:

      在我的具体情况下,我使用的是不推荐使用的 expo/ex-navigation 版本,在 RN 0.64.2 中我们遇到了一个问题,因为 RN 不理解 @2x.android 或类似的转换来选择正确的图像为一个图标。问题在此处描述:#31348

      我在 node_modules 中本地出售了我的冲突并让 Android 正常工作(然后我分叉并在我的控制下创建了一个更正),但是当我回来处理我的 IoS 问题时,我忘记了使用这个更正。

      所以,我的问题出现在我的 node_modules 中的一个库中,并且当我广泛搜索时,这个问题经常发生在这种情况下。

      因此,如果 @takameyer 解决方案对我不起作用,我建议您查看您的 node_modules 依赖项...

      可能尝试构建你的包认为 react-native-cli 会给你一个更好的日志然后在 xcode 中构建它,因为在我的情况下 xcode 构建工作但给我一个运行时错误(发布)。

      我希望它对将来的人有所帮助。

      【讨论】:

        【解决方案5】:

        这种崩溃原因是当您的目标是发布模式并且您的捆绑包是开发模式时。

        所以我的 iOS 目标设置为 Release

        我的包被构建到开发,使用这个命令:

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

        为了解决这个问题,我用这个命令再次构建了我的包。

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

        并且有效。

        感谢@sumizome 和@strdr4605 我用你的回答做了这个。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-05-06
          • 2021-06-10
          • 2023-03-29
          • 2019-09-13
          • 2021-05-22
          • 2019-08-27
          • 2020-09-02
          相关资源
          最近更新 更多