Xcode script

4 views
Skip to first unread message

Patrick McConnell

unread,
Nov 18, 2015, 9:27:26 AM11/18/15
to Albany Cocoaheads
Hello Cocoa folks,

Here is the script I was showing you last night. This does two things. It will put any TODO: or FIXME: into the alerts panel on the left of the editor view (command-4) I also automatically increments the build number.

Another thing we discussed was the new pragma syntax for swift. It supports MARK, TODO and FIXME by default but they only show in the method listings of the jump bar. The syntax is MARK: or MARK: - to underline it in the menu.

Here is a tip. Group all your delegate methods with a mark like so

MARK: - UITableViewDelegate.

If the protocol name is correct it will both appear in your menu and give you a target in the editor to option or command click to show the documentation or take you right to the definition of the protocol. Try it and it will make more sense.

I can’t take credit for these as I got them from some google searches.

If you want to add them. Select your target then the build phases tab. In the upper left of the build phases page click the + and select 'new run script phase’ This will insert a new empty run script component into your build process. Cut and paste the script below and you should be all set.

p.

Script below:

TAGS="TODO:|FIXME:"
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/"

echo "${PROJECT_DIR}/${INFOPLIST_FILE}"
buildVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"

Reply all
Reply to author
Forward
0 new messages