Created
March 27, 2017 05:56
-
-
Save ChiChou/e9d3569af22cadd3c8f925e9fcfdd4bd to your computer and use it in GitHub Desktop.
fix header generated from class-dump
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
#!/bin/bash | |
# | |
# NOTE: You need to `brew install gnu-sed` on Mac | |
# | |
# by @codecolorist | |
# http://github.com/chichou | |
# | |
# fix some compilation error of headers generated by class-dump | |
# | |
# usage: fixheader.sh DIRECTORY | |
usage() { | |
echo "Fix compilation error of headers generated by class-dump" | |
echo | |
echo "Usage: $0 {PATH}" | |
} | |
if [ ! -d "$1" ]; then | |
echo "Invalid path $1" | |
usage | |
exit 1 | |
fi | |
for filename in $1/*.h; do | |
if [ 'Darwin' == $(uname) ]; then | |
sed="gsed" | |
else | |
sed="sed" | |
fi | |
# remove "- (void).cxx_destruct;" | |
# replace "CDUnknownBlockType" with "id" | |
# fix missing NSObject.h | |
$sed -i -e '/- (void).cxx_destruct;/d' -e "s/\bCDUnknownBlockType\b/id/g" \ | |
-e "s/#import \"NSObject.h\"/#import <Foundation\/NSObject.h>/" $flag $filename | |
# remove -Protocol suffix | |
if [[ $filename == *"-Protocol.h" ]]; then | |
echo "rename $filename" | |
mv "$filename" "${filename%-Protocol.h}.h"; | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment