Experienced old Objective-C developers like myself appreciated the #warning(...)
tag in source code. It was a great way to remind yourself of things that might otherwise get lost in TODO comments that you forget to search for or your colleague is unaware of. Then it went away in Swift, and people like this guy came up with his own solution, which I liked for a while because it was truly customizable by keyword. Then Apple put #warning(...)
back and that became less of an important thing to use.
…. Until I started working on Source Code that is to become a Cocoapod. For if you try to run pod lint spec MySpec.podspec
, and there are compiler warnings, the validation process will fail.
So, return of the Run Script that goes through your Swift files and searches for keywords and adds warnings or errors as appropriate.
You can see the original post, or just create a run script (I think before you compile sources but I don’t think it matters), and add this (modify keywords as you like):
TAGS="TODO:|FIXME:" ERRORTAG="ERROR:" find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/"