Redirect console prints from Xcode - ios

While developping an app for an iPad on my Mac, I use print logs to monitor what is going on (regular prints in Swift code). However I really don't like the Xcode console, and I'd like to be able to redirect the stream to a file, where I can then read it with a better log viewer (and add color!).
I'm executing the app in debug mode through Wifi on my iPad, but I want the logs on my Mac, so storing the logs to a file on the device is not really interesting (SO question here). Wrapping the debugger executable seems interesting, as suggested here but I couldn't find anything more recent (with lldb).
Alternatively, I could also run the debugger from the console and handler the redirection from there, but I don't know how to do that for debugging on a remote device over WiFi.
Any help would be greatly appreciated!

Related

Is there a way to access the console logs of a live React Native app (i.e. not running locally)?

I have a live RN app with some console logs in the code. I want to know if you can still somehow see console logs in production, just like you can if you open dev tools in a browser on a production website.
I've seen lots of answers such as this one suggesting to shake the device and use a debugger, but that only works for local emulators.
Do the logs get stored to the phone (iOS) somewhere, perhaps?

Access to iOS device's console output

Is there an iOS app which allows to look at console output created by another iOS app?
My app has several NSLog() calls which output precise timings. I would like to test the app, when it is not connected to my development Mac, and look at timings after that, possibly still on my iDevice using some other "console browser" app.
Is that possible?
So the way to do this is to use the Apple System Logger which allows you to access the logs and you can then display them on screen. NSLog will be logged to this. I wrote something a few years ago so that testers could test the app and open the log and view it on the device.
Its a bit tricky to use the interface and there is a limit, I think it was 200, on the number of logs in the cache, so log only the necessary stuff.
After a quick search, I found this - SOLogger which should help you.

How can I get live console output when device is connected to another hardware device?

So I'm trying to make an application using the DJI SDK. In order for my app to function properly, my iDevice needs to be hooked up to the remote controller of the drone via USB.
This means I can't also run the app via xcode and get console output.
Is there a way of saving console output when using an app on your phone? I am aware of the crash logs, but sadly they don't provide enough info to be useful to me.
This problem started when I got a runtime error only when the device was connected to the remote controller. Therefore there was no way of isolating the problem since I couldn't tell what went wrong.
Another solution would maybe be a 1 female to 2 male usb chord, but I haven't found one online yet and even if I did I don't know if that would work.
Is there a standard way of debugging when using hardware that needs to be connected to the device?
from Xcode, hit window on the tool bar at the top, then Devices. Select the device you want to read the log from. However, this is the log for the entire phone, and you have to be plugged into the mac... so you'll have to run your tests, unplug from the DJI, plug into the mac, go to devices, and scroll through the log until you find the output from your app, and you won't be able to see real time expected outcome.
It's not ideal, but that's the only way I know of to see the apart from building an entire console log into your app yourself.

How to read apple system log (asl) in simulator in Objective-c?

I'm using something similar to this code to read the console on a physical device, which works great. (Using iOS 7.1.2 on an iPhone 5.)
However, when I run it on the iOS Simulator (7.1.2 and Xcode 5.1.1), I get no responses from asl_search.
I've found this question which looks like it would be a duplicate, but it doesn't specify programmatic reading of the logs. So there are various solutions that require knowledge of where the actual log files live on disk.
Is there a reliable way to get asl logs on the simulator from within my app's objective-c code?
I'd like to be able to say "if device, read from asl, else if simulator, get some other way".
Is there some library that abstracts the differences in where the logs are stored? Ideally I'd like to get the log data back in the same format, so I can handle it the same way whether I'm running on a device or the simulator.
Also, I know I can't get the full syslog past iOS 6, on a real device. That's OK--I just want a way to get whatever info is available, even if it's just logs from my own app.

How can we print the contents of GDB or log statements on the device(iPad)

This question might be a bit strange and i apologize for that... i have rather a strange problem with my iPad app. My app is running absolutely fine when i connect the device to my system and run the app. But,it is getting crashed repeatedly once i try to use the app after disconnecting it from my system. This is very strange to me. I am unable to even debug this because of this strange issue. i need at least GDB log to debug my code.So, is there any way in which i can print my GDB log on my device(iPad)... At least is there any other way in which i can solve this strange issue...
Is it crashing while you are debugging and then disconnect the device. If you disconnect your device while debugging, the app will stop on your device and you need to reopen it to continue using it on the device.
If you want the Logs stored on your device, connect your device to your Mac and in Xcode go to Window -> Organiser. Select the Devices Tab and on the left should be your Device and an option to view the Device Logs which should get you the same Crash Logs you get in the Debugger Output window. Xcode will Symbolise them if it can so you should be able to debug the issue. It will also show Crash Logs for Applications you do not develop but those will not be Symbolised so won't make much sense.
Alternatively, if you choose the Console option you'll be able to see the Console output which will show all your NSLog outputs. It will also have some Device Specific output which you can ignore.
Use NSLog(), you can read the resulting console entries in the Xcode organiser after connecting the device via USB:

Resources