Swift: #warning equivalent

前端 未结 14 1667
無奈伤痛
無奈伤痛 2020-11-28 18:52

Does Swift have a #warning equivalent? It\'s simply used to show a warning in Xcode\'s own GUI

I\'m also interested in whether there\'s a #error equivalent.

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 18:58

    One CocoaPod that I was using had .swift in its name, so a directory was returned, which caused the script by Kyle to crash. Adding -type f to the find command fixes that problem by only looking at files that match *.swift instead of also returning directories that match the pattern.

    Final code that I used:

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

提交回复
热议问题