0

I'm not even sure this is possible, but I'll give it a shot.

Is it somehow possible (i.e. with a plugin) for Xcode to check if every File contains a valid license header, and if not stops compiling?

Thanks in advance.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
dominik
  • 1,319
  • 13
  • 23

2 Answers2

2

Here is the complete Setup! Note that this will produce Xcode erros too. :)

#!/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

And here is how to setup the Script: Xcode: Running a script before every build that modifies source code directly

How to report Errors in Xcode: http://shazronatadobe.wordpress.com/2010/12/04/xcode-shell-build-phase-reporting-of-errors/

Community
  • 1
  • 1
dominik
  • 1,319
  • 13
  • 23
1

Well im not sure if this is the correct answer, but you could add a shell script to your build phase which could check the files in your project for the valid license header (via grep+regex).

Matt Bro
  • 381
  • 2
  • 3
  • Thanks I didn't know this was possible. I'll post back once I've got everything up and running. – dominik Jun 05 '13 at 10:02