简体   繁体   English

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

[英]React-native cannot open ios simulator debug menu

I have a react-native project that I develop with an ios simulator (iPhone 8 mostly).我有一个 react-native 项目,我使用 ios 模拟器(主要是 iPhone 8)开发。 I can't seem to open the debug menu with the regular command ⌘ + D.我似乎无法使用常规命令 ⌘ + D 打开调试菜单。

I recently started applying pods as a way of integrating dependencies in my project, as I needed a specific library that requires it.我最近开始应用 pod 作为在我的项目中集成依赖项的一种方式,因为我需要一个需要它的特定库。 After that change, I've no longer been able to open the debug menu (nor refresh the simulator app) with controls such as ⌘ + D and ⌘ + R.更改后,我再也无法使用 ⌘ + D 和 ⌘ + R 等控件打开调试菜单(也无法刷新模拟器应用程序)。 I've also tried to open those from the simulator top menu, with no luck.我也尝试从模拟器顶部菜单中打开那些,但没有运气。 Shake gesture does not work either, no luck there.摇动手势也不起作用,那里没有运气。

The way Im running my app is as follows:我运行我的应用程序的方式如下:

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

I think it should resolve to debug mode and not release mode?我认为它应该解析为调试模式而不是发布模式? Because one thing that could explain why the debug menu won't open is that the application is in release mode, where debug menu is not supported.因为可以解释为什么无法打开调试菜单的一件事是应用程序处于发布模式,其中不支持调试菜单。 But this shouldn't be the case because I just run it with the basic react-native run-ios command.但这不应该是这样,因为我只是使用基本的react-native run-ios命令运行它。 How could I 100% be sure that it is not in release mode?我怎么能 100% 确定它没有处于发布模式? I could open an alert from the app to test it (since console.log won't show because can't get to the debug menu).我可以从应用程序中打开一个警报来测试它(因为 console.log 不会显示,因为无法进入调试菜单)。 Also once I start the app it shows this in terminal:同样,一旦我启动应用程序,它就会在终端中显示:

info Building using "xcodebuild -workspace MyApp.xcworkspace -configuration Debug -scheme MyApp -destination id=356D169E-E11E-44B2-8AEF-015D0F24A203 -derivedDataPath build/MyApp"使用“xcodebuild -workspace MyApp.xcworkspace -configuration Debug -scheme MyApp -destination id=356D169E-E11E-44B2-8AEF-015D0F24A203 -derivedDataPath build/MyApp”构建信息

And that -configuration flag with a value Debug would indicate that it's not in release mode.带有 Debug 值的 -configuration 标志将表明它不在发布模式下。

My Podfile looks following:我的 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

Could it be that the DevSupport module that enables the in-app debug menu is not properly installed?难道是没有正确安装启用应用内调试菜单的DevSupport模块? I mean this one:我的意思是这个:

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

I've tried many answers from similar questions without success.我已经尝试了许多类似问题的答案,但都没有成功。

My react-native version is: 0.59.10我的 react-native 版本是:0.59.10

Was able to fix this by removing the use_frameworks!能够通过删除use_frameworks! line from my Podfile.我的 Podfile 中的行。 I guess Im lucky for not using any dynamic frameworks in my app, so was able to fix it with this solution.我想我很幸运没有在我的应用程序中使用任何动态框架,所以能够用这个解决方案修复它。 But I understand this is not optimal.但我知道这不是最优的。 So if someone figures a better alternative I might accept it instead.因此,如果有人想出更好的选择,我可能会接受它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM