Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you redirect log output of Xcode console to Terminal when running iPhone Simulator?

Tags:

I don't like using Xcode's console output window when debugging an iPhone app in the Simulator (or on a device for that matter). I'd like to be able to use the Unix toolbox and do things like filter the logging output with grep. But to do this I need to get Xcode to send the logging output for the running iPhone app to the Terminal.

Is there any way to accomplish this?

like image 737
dan Avatar asked Dec 15 '09 20:12

dan


People also ask

How do I use the console log in iOS simulator?

Open your page in Safari on the Simulator and then go to Safari Technology Preview > Develop > Simulator. Show activity on this post. Show activity on this post. I can open the log directly via the iOS simulator: Debug -> Open System Log...

Where is the console log in Xcode?

You need to click Log Navigator icon (far right in left sidebar). Then choose your Debug/Run session in left sidebar, and you will have console in editor area.


1 Answers

Couldn't say how it'd work in the simulator, but redirecting stdout is not terribly difficult. Say you wanted to pipe it into your own view:

#include <unistd.h>

stderr->_write = RedirectOutputToView;
stdout->_write = RedirectOutputToView;

And use the prototype:

int RedirectOutputToView(void *inFD, const char *buffer, int size);
like image 118
Azeem.Butt Avatar answered Oct 12 '22 21:10

Azeem.Butt