【问题标题】:Xcode check for license headerXcode 检查许可证头
【发布时间】:2013-05-31 23:03:35
【问题描述】:

我什至不确定这是否可能,但我会试一试。

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

提前致谢。

【问题讨论】:

    标签: xcode scripting comments licensing


    【解决方案1】:

    这是完整的设置!请注意,这也会产生 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/

    【讨论】:

      【解决方案2】:

      我不确定这是否是正确的答案,但是您可以在构建阶段添加一个 shell 脚本,该脚本可以检查项目中的文件是否有有效的许可证头(通过 grep+regex)。

      【讨论】:

      • 谢谢,我不知道这是可能的。一切就绪后,我会回帖。
      猜你喜欢
      • 2021-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多