You have to add a new custom Run Script Build Phase, in Xcode:

 Project > New Build Phase > New Run Script Build Phase  

and use the next run script:

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/"

Run Script Description

Line 1 defines the keywords we want to search for. If you want to exclude a keyword or 
include a different one, edit this line.

Line 2 uses the find command to generate a list of all files in your project directory 
(SRCROOT) having an .h or .m extension. 
If you want to search more files, you will need to edit this line.

Line 3 uses xargs to pass those file names along to egrep, which searches inside the files 
for lines containing one of the keywords. If any are found, it outputs the file name, 
line number, and the matching part of the line.

Line 4 uses Perl to format the lines as warnings.

Blog Logo

Daniel Gomez Rico




The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview