2013-06-05 32 views
0

我甚至不确定这是可能的,但我会给它一个镜头。Xcode检查许可证标题

Xcode是否有可能(即使用插件)检查每个文件是否包含有效的许可证标题,并且如果不停止编译?

在此先感谢。

回答

2

这是完整的设置!请注意,这也会产生Xcode错误。 :)

#!/bin/bash 

searchString=`cat license.txt` 

ERROR_COUNT=0 
while read file 
do 
    grep -F "${searchString}" $file > /dev/null 
    if [ $? -ne 0 ]; then 
     echo -e $file:1: error : No valid License Header found! 1>&2 
     ERROR_COUNT=1 
    fi 
done < <(find . -type d \(-name "TTTAttributedLabel" -o -name "minizip" -o -name "SSZipArchive" \) -prune -o -type f \(-name "*.m" -o -name "*.h" -o -name "*.pch" \) -print) 


exit $ERROR_COUNT 

这里是如何设置的脚本: Xcode: Running a script before every build that modifies source code directly

如何在Xcode中报告错误: http://shazronatadobe.wordpress.com/2010/12/04/xcode-shell-build-phase-reporting-of-errors/

1

那么我不知道这是否是正确的答案,但您可以添加一个shell脚本到您的构建阶段,它可以检查项目中有效许可证标题(通过grep +正则表达式)中的文件。

+0

谢谢,我不知道这是可能的。一旦我把所有的东西都运转起来,我会回来。 – dominik