Skip to content

Instantly share code, notes, and snippets.

@matsuda
Last active May 15, 2018 16:21
Show Gist options
  • Save matsuda/00558ac96ad8cd67a22f to your computer and use it in GitHub Desktop.
Save matsuda/00558ac96ad8cd67a22f to your computer and use it in GitHub Desktop.
Warning script in swift project
# http://bendodson.com/weblog/2014/10/02/showing-todo-as-warning-in-swift-xcode-project/
TAGS="TODO:|FIXME:|WARNING:"
echo "searching ${SRCROOT} for ${TAGS}"
# find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
find "${SRCROOT}/${PROJECT_NAME}" \( -name "*.swift" ! -type d \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
TARGETS > Build Phases > New Run Script Phase
```
// download xc_build_alert.sh
chmod +x xc_build_alert.sh
```
```
/bin/sh
"${SRCROOT}/xc_build_runners/xc_build_alert.sh"
```
#!/bin/bash
##########################################
#
# Report errors and warnings
#
# refs.
# http://bendodson.com/weblog/2014/10/02/showing-todo-as-warning-in-swift-xcode-project/
# http://www.mokacoding.com/blog/better-build-phase-scripts/
#
# Author: matsuda
#
##########################################
set -e
set -o nounset
TAGS="TODO:|FIXME:|WARNING:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}/${PROJECT_NAME}" \( -name "*.swift" ! -type d \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
@matsuda
Copy link
Author

matsuda commented May 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment