Can you add custom compiler warnings in Objective-C? Can you add custom compiler warnings in Objective-C? xcode xcode

Can you add custom compiler warnings in Objective-C?


It's very easy to do:

#warning Needs better error handling, please.


Select your target and then select the Build Phases tab. At the bottom of the window you’ll see an option to Add Build Phase at the bottom of the screen. You can use the Add Build Phase to add a Run Script build phase. The Run Script option allows you to select a shell and execute arbitrary code against the project.

To warn about TODO & FIXME comments, use /bin/sh as the shell and paste in this script:

TAGS="TODO:|FIXME:"echo "searching ${SRCROOT} for ${TAGS}"find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"

Source : Generate Xcode Warnings from TODO Comments