I have a script to show all my //TODO:
comments which looks like this:
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 |
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
perl -p -e "s/($KEYWORDS)/ warning: \$1/"
I want to exclude my Pods
folder, therefore I have added -not -path "./Pods/*"
:
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 |
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
perl -p -e "s/($KEYWORDS)/ warning: \$1/"
This works as expected when I try it on the Terminal (replacing "${SRCROOT}"
with "."
), but when it is run by Xcode it uses the Pods
folder as well.
How can I exclude the folder in the build phase script?
Final version
This seems to work:
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "." \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 |
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
perl -p -e "s/($KEYWORDS)/ warning: \$1/"
I couldn't get it to work correctly without using ${SRCROOT} macro, as you couldn't click on the warning to go to the source line.
I split up the recognized tokens into Warnings and Errors for my own use, thought I would share it here:
KEYWORDS="STUB:|WARNING:|TODO:|FIXME:|DevTeam:|\?\?\?:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: warning: \$1/"
KEYWORDS="ERROR:|XXX:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"
ERROR_OUTPUT=`find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"`
exit ${#ERROR_OUTPUT}
I would use find .
and set the working directory of the build script to ${SRCROOT}
. This should allow the .
in -not -path "./Pods/*"
to make sense to find
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With