Reputation: 763
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.
When I run the application from XCode however, the application runs just fine. Awesome!
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?
Upvotes: 20
Views: 37501
Reputation: 66
If you close the app on the device (so that XCode shows it as stopped) and then start the app again (through the device, not with XCode), the console logs will go to the terminal (assuming metro is running).
Of course, you don't get XCode debug logs, for my needs that's fine.
Upvotes: 1
Reputation: 1463
It seems that react-native log-ios
is not working anymore since RN .50
You can use react-native-log-ios
npm package instead
npm i -g react-native-log-ios
and then
react-native-log-ios <XCode Project Name>
Upvotes: 12
Reputation: 2822
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.
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
cmd ⌘ + D to bring up the debug menu
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, 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
This bundled without "dev-mode" on. To allow dev messages, include the --dev
flag:
react-native bundle --dev
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!).
Upvotes: 16