Created
October 8, 2013 20:18
-
-
Save jazzychad/6890924 to your computer and use it in GitHub Desktop.
Extracts private methods from a .m class file and creates a Class+Private.h class extension - somehow turning this into an Xcode plugin would also be cool.
This file contains 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
#!/bin/bash | |
# change PREFIX to match whatever you use to denote private | |
# methods internally in .m files | |
# e.g. | |
# - (void)_privateMethod | |
PREFIX="_" | |
if [ $# -eq 0 ] | |
then | |
echo "usage: $0 <class_file>.m" | |
echo | |
echo "outputs a Class+Private.h file with internal private method" | |
echo "signatures as determined by the defined method prefix" | |
exit 1 | |
fi | |
if [ ! -f $1 ] | |
then | |
echo "$1 is not a file. Aborting." | |
exit 1 | |
fi | |
FILE=`basename $1` | |
CLASS="${FILE%.*}" | |
OUTFILE="$CLASS+Private.h" | |
echo "#import \"$CLASS.h\"" > $OUTFILE | |
echo >> $OUTFILE | |
echo "@interface $CLASS ()" >> $OUTFILE | |
echo >> $OUTFILE | |
egrep "^[-+][ ]?\(.*\)[ ]?$PREFIX" $1 | awk '{print $0 ";"}' | sort >> $OUTFILE | |
echo >> $OUTFILE | |
echo "@end" >> $OUTFILE | |
cat $OUTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. I could really use this.