Skip to content

Instantly share code, notes, and snippets.

@seivan
Forked from jazzychad/private_header
Created March 29, 2014 22:29
Show Gist options
  • Select an option

  • Save seivan/9864075 to your computer and use it in GitHub Desktop.

Select an option

Save seivan/9864075 to your computer and use it in GitHub Desktop.
#!/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