Skip to content

Instantly share code, notes, and snippets.

@eMdOS
Created July 21, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eMdOS/d6ec6724041b48544b0e3b0666afd63c to your computer and use it in GitHub Desktop.
Save eMdOS/d6ec6724041b48544b0e3b0666afd63c to your computer and use it in GitHub Desktop.
Xcode: code comments warning (TODO: | FIXME: | WARNING: | ERROR:)

Xcode (code comments warnings)

  1. Create the scripts folder at ./:

    mkdir scripts
  2. Give it the right permissions for execution:

    chmod -R u+x scripts
  3. Create xcode_warnings.sh file at ./scripts/:

    1. Moving to scripts folder:

      cd scripts
    2. Creating xcode_warning.sh file:

      touch xcode_warnings.sh
  4. In xcode_warnings.sh add the following code:

    #!/bin/bash
    
    TAGS="TODO:|FIXME:|WARNING:"
    ERRORTAG="ERROR:"
    
    OUTPUT=$(find "${SRCROOT}" -name "*.h" -or -name "*.m" -or -name "*.swift" \( -not -path "${SRCROOT}/Carthage/*" \) -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/")
    
    ECHO "$OUTPUT"
    
    if [[ $OUTPUT == *" error: "* ]]
        then
        exit 1
    fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment