React-native 无法打开 ios 模拟器调试菜单

React-native cannot open ios simulator debug menu

我有一个使用 ios 模拟器(主要是 iPhone 8)开发的 react-native 项目。我似乎无法使用常规命令 ⌘ + D 打开调试菜单。

我最近开始应用 pods 作为在我的项目中集成依赖项的一种方式,因为我需要一个需要它的特定库。更改之后,我不再能够使用 ⌘ + D 和 ⌘ + R 等控件打开调试菜单(也无法刷新模拟器应用程序)。我还尝试从模拟器顶部菜单中打开它们,使用没有运气。摇一摇也不行,运气不好

我 运行 安装我的应用程序的方式如下:

ENVFILE=.env.ios-development react-native run-ios --simulator 'iPhone 8'

我觉得应该解析为debug模式而不是release模式?因为可以解释为什么调试菜单无法打开的一件事是应用程序处于发布模式,不支持调试菜单。但这不应该是这种情况,因为我只是用基本的 react-native run-ios 命令 运行 它。我怎么能 100% 确定它不处于发布模式?我可以从应用程序打开一个警报来测试它(因为 console.log 不会显示,因为无法进入调试菜单)。此外,一旦我启动应用程序,它就会在终端中显示:

info Building using "xcodebuild -workspace MyApp.xcworkspace -configuration Debug -scheme MyApp -destination id=356D169E-E11E-44B2-8AEF-015D0F24A203 -derivedDataPath build/MyApp"

并且值为 Debug 的 -configuration 标志表示它未处于发布模式。

我的 Podfile 如下所示:

project 'MyApp.xcworkspace'

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

# Allowed sources
source 'https://github.com/CocoaPods/Specs.git'

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

  # Pods for myapp

  # Point to the installed version
  pod 'RNDateTimePicker', :path => '../node_modules/@react-native-community/datetimepicker/RNDateTimePicker.podspec'

  # React/React-Native specific pods
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',      # Include this for RN >= 0.47
    'DevSupport',     # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',   # Needed for debugging
  ]

  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  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'

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

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

end

会不会是启用应用内调试菜单的DevSupport模块没有安装好?我是说这个:

'DevSupport',     # Include this to enable In-App Devmenu if RN >= 0.43

我尝试了很多类似问题的答案,但都没有成功。

我的 react-native 版本是:0.59.10

能够通过从我的 Podfile 中删除 use_frameworks! 行来解决这个问题。我想我很幸运没有在我的应用程序中使用任何动态框架,所以能够用这个解决方案修复它。但我知道这不是最优的。因此,如果有人想出更好的选择,我可能会接受它。