在XCode中导出文件中的所有警告 [英] export all warnings in file in XCode

查看:267
本文介绍了在XCode中导出文件中的所有警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了显示Xcode警告的脚本。例如 TODO 警告。此脚本将在每个XCode版本上运行。 (我在运行阶段选项中编写了脚本)。

I have written script that shows Xcode warnings. e.g TODO warnings. This script will run on each build of XCode. (I have written script in "Run Phase" option).

现在我想收集并将所有这些警告导出到文本文件。有没有办法将所有警告或构建错误导出到文本文件?

Now I want to collect and export all these warnings to text files. Is there any way to export all warnings or build errors to a text file?

推荐答案

(这是你的第一位已经完成,或类似的东西)

(the first bit of this is what you've already done, or something like it)

选择你的单击Build Phases选项卡,然后从'Editor'菜单中选择'Add Build Phase> Add Run Script Build Phase'。

Select your project, click the Build Phases tab, and select 'Add Build Phase > Add Run Script Build Phase' from the 'Editor' menu.

在脚本框中使用脚本类似这样的事情:

In the script box use a script something like this:

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"

(礼貌: http://deallocatedobjects.com/ posts / show-todos-and-fixmes-as-warnings-in-xcode-4

KEYWORDS 正则表达式匹配 TODO: FIXME: ???: !!!:,但可以调整以找到你想要的任何指标。

The KEYWORDS regular expression matches TODO:, FIXME:, ???: and !!!:, but could be adjusted to find whichever indicators you want.

脚本当前输出到 stdout ,由XCode和解析。要使它也记录到文件,请使用 tee 作为脚本的一部分(请参阅第2行末尾的更改):

The script currently outputs to stdout, which is picked up by XCode and parsed. To make it also log to a file, use tee as part of the script (see the end of line 2 for the change):

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/" | tee "${SRCROOT}/NOTICES.txt"

这种方法可以像你想的那样复杂,当然,以及 tee 输入文件,我们可以扩充脚本以执行我们选择的任何操作:

This approach can be as complex as you like, of course, as well as teeing to a file, we can augment the script to do anything we choose:

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/" | tee ${SRCROOT}/NOTICES.txt
mail -s NOTICES idmillington@example.com < ${SRCROOT}/NOTICES.txt

通过电子邮件发送给我。

That emails it to me.

我已经确认这适用于XCode 5.0.2,包括发送电子邮件。

I've confirmed this works with XCode 5.0.2, including emailing.

注意这不会将构建中的所有警告导出到文件,这完全是您所要求的。我找不到在XCode 5.0.2中自动执行此操作的方法,但您可以使用 xcodebuild 来实现。在UI中,唯一的选择是将日志文本从日志导航器复制到剪贴板。

Note that this does not export all warnings from the build to a file, which is strictly what you asked. I can't find a way to automate this in XCode 5.0.2, though you can do it with xcodebuild. From within the UI, the only option is to copy the log text from the log navigator to the clipboard, it seems.

这篇关于在XCode中导出文件中的所有警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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