React Native:当我从XCode运行应用程序时看不到console.logs [英] React Native: Can't see console.logs when I run application from XCode

查看:1511
本文介绍了React Native:当我从XCode运行应用程序时看不到console.logs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让我的代码使用 react-native run-ios 。本机代码正在拉动javascript包的一些旧缓存版本,我似乎无法清除它以挽救我的生命。

I'm struggling to get my code working with react-native run-ios. The native code is pulling some old cached version of the javascript bundle, and I can't seem to clear that to save my life.

当我从XCode运行应用程序时但是,应用程序运行得很好。真棒!

When I run the application from XCode however, the application runs just fine. Awesome!

唯一的问题是,当我通过XCode运行我的应用程序时,我似乎无法访问javascript日志。我已经尝试了 react-native log-ios ,但这似乎没有显示我的日志。我从模拟器菜单尝试了在Chrome中启用调试,但是当我从XCode运行应用程序时,我无法使用此选项。

The only problem is that when I run my application through XCode, I can't seem to access the javascript logs. I've tried react-native log-ios but that doesn't seem to show my logs. I've tried "Enabling debugging in Chrome" from the simulator menu, but this option isn't available to me when I run the app from XCode.

有没有人有关于可能会发生什么的任何想法?

Does anybody have any thoughts on what might be going on here?

推荐答案

选项#1



console.log 有效。默认情况下,在iOS上,它会记录到Xcode内的调试窗格。如果您从愤怒摇动菜单(⌘+ ^ + Z)中选择在Chrome中调试或在Safari中调试选项,它将改为登录浏览器控制台。

Option #1

console.log works. By default on iOS, it logs to the debug pane inside Xcode. If you select the "Debug in Chrome" or "Debug in Safari" options from the rage shake menu (⌘+^+Z), it will log to the browser's console instead.

从React Native 0.29开始,您将能够简单地运行以下内容请参阅命令行上的日志:

As of React Native 0.29 you'll be able to simply run the following to see logs on the command line:

react-native log-ios
react-native log-android



选项#3



Option #3


  1. cmd⌘ + D 打开调试菜单

关闭在Safari中调试设置,并将一些消息打印到输出消息,而不是控制台消息。但是,其中一条日志消息显示:

Set "Debug in Safari" turned off, and some messages would be printed to the output message, but not console messages. However, one of the log message says:


DEV === false,开发级警告为OFF ,性能优化是开启的

DEV === false, development-level warning are OFF, performance optimizations are ON"

这是因为我之前使用以下命令将我的项目捆绑在一个真实设备上进行测试:

This was because I had previously bundled my project for testing on a real device with the command:

react-native bundle --minify

这个捆绑没有dev-mode打开。要允许开发消息,请包含 - dev 标志:

This bundled without "dev-mode" on. To allow dev messages, include the --dev flag:

react-native bundle --dev

react-native bundle --dev

console.log 消息又回来了!如果您没有捆绑真实设备,请不要忘记在 AppDelegate.m jsCodeLocation >到localhost(我做了!)。

And console.log messages are back! If you aren't bundling for a real device, don't forget to re-point jsCodeLocation in AppDelegate.m to localhost (I did!).

这篇关于React Native:当我从XCode运行应用程序时看不到console.logs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆