Created
March 20, 2014 13:28
-
-
Save cokecoffe/9663687 to your computer and use it in GitHub Desktop.
iOS/Xcode/build script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.把TODO,FIXME等注释转化为编译结果中的警告 | |
#!/bin/sh | |
# 把TODO,FIXME等注释转化为编译结果中的警告 | |
# by Kellen Styler | |
# via: http://d3signerd.com/turn-fixme-todo-and-comments-into-compiler-warnings/ | |
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:" | |
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/" | |
2.编译时自增构建数 | |
#!/bin/sh | |
# 自增构建数 | |
# via: http://stackoverflow.com/q/9258344 | |
plist=${PROJECT_DIR}/${INFOPLIST_FILE} | |
dir="$(dirname "$plist")" | |
# 仅当文件有修改时自增 | |
if [ -n "$(find "$dir" \! -path "*xcuserdata*" \! -path "*.git" -newer "$plist")" ]; then | |
buildnum=$(/usr/libexec/Plistbuddy -c "Print CFBundleVersion" "$plist") | |
if [ -z "$buildnum" ]; then | |
echo "No build number in $plist" | |
exit 2 | |
fi | |
buildnum=$(expr $buildnum + 1) | |
# 或使用日期(形如:121204): | |
# buildnum=$(date "+%y%m%d") | |
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "$plist" | |
echo "Incremented build number to $buildnum" | |
else | |
echo "Not incrementing build number as source files have not changed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment