运行iPhone Simulator时,可以将Xcode控制台的日志输出重定向到Terminal吗? [英] Can you redirect log output of Xcode console to Terminal when running iPhone Simulator?

查看:166
本文介绍了运行iPhone Simulator时,可以将Xcode控制台的日志输出重定向到Terminal吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模拟器(或设备)中调试iPhone应用程序时,我不喜欢使用Xcode的控制台输出窗口。我希望能够使用Unix工具箱并执行诸如使用grep过滤日志记录输出的操作。但是要做到这一点,我需要让Xcode将正在运行的iPhone应用程序的日志记录输出发送到终端。

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?

推荐答案

无法说出它在模拟器中的工作方式,但是重定向标准输出并不是很难。假设您想将其传递到您自己的视图中:

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;

并使用原型:

int RedirectOutputToView(void *inFD, const char *buffer, int size);

这篇关于运行iPhone Simulator时,可以将Xcode控制台的日志输出重定向到Terminal吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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