|
class_dump_z
class-dump-z — Extracting class interface for Objective-C version 2 ABI.
Phase-Support Download:
Usage: class-dump-z [<options>] <filename>
where options are:
Analysis:
-p Convert undeclared getters and setters into properties (propertize).
-h proto Hide methods which already appears in an adopted protocol.
-h super Hide inherited methods.
-y <root> Choose the sysroot. Default to the path of latest iPhoneOS SDK, or /.
-u <arch> Choose a specific architecture in a fat binary (e.g. armv6, armv7, etc.)
Formatting:
-a Print ivar offsets
-A Print implementation VM addresses.
-k Show additional comments.
-k -k Show even more comments.
-R Show pointer declarations as int *a instead of int* a.
-N Keep the raw struct names (e.g. do no replace __CFArray* with CFArrayRef).
-b Put a space after the +/- sign (i.e. + (void)... instead of +(void)...).
-i <file> Read and update signature hints file.
Filtering:
-C <regex> Only display types with (original) name matching the RegExp (in PCRE syntax).
-f <regex> Only display methods with (original) name matching the RegExp.
-g Display exported classes only.
-X <list> Ignore all types (except categories) with a prefix in the comma-separated list.
-h cats Hide categories.
-h dogs Hide protocols.
Sorting:
-S Sort types in alphabetical order.
-s Sort methods in alphabetical order.
-z Sort methods alphabetically but put class methods and -init... first.
Output:
-H Separate into header files
-o <dir> Put header files into this directory instead of current directory.
Why a yet another class-dump?class-dump is a command-line tool to extract Objective-C class interfaces, written by Steve Nygard 17 years ago. The development however paused in 2007 at version 3.1.2, without support for the newest ABI. This caused the birth of class-dump-x by Holly Lee in 2008. But being a straight modified version of class-dump, it inherited some of the problems, e.g. the ivar offsets are calculated wrongly, properties are not supported, etc. I, using class-dump-x a lot for reverse engineering, finds that the ivar offset problem is hard to get over with. Having no answers a few months after a bug report, I decided to just fix the problem myself — hence class-dump-z is started. (While I was creating class-dump-z, the original class-dump development suddenly reactivated at July 1st. The newest version 3.2 does support 2.0 ABI now, but the ivar offset info is even worse than class-dump-x.) Why you don't want to use class-dump-zInstead of a generic-purpose class dumper, class-dump-z was written with iPhoneOS development in mind. Therefore, the following features will probably never be implemented:
Features10x the speed
class-dump-z is written from scratch using C++ avoiding using dynamic calls, unlike class-dump and class-dump-x which are written in Objective-C. Removing these unnecessary calls makes class-dump-z near 10 times faster than the precedences. Portable
Since class-dump-z is written in C++, it is very easy to port to other platforms. Currently Mac OS X 10.6, iPhoneOS 3.1, Linux (x86 and amd64) and Windows (≥XP) are officially supported. Correct ivar offsets
Generating ivar offsets by accumulation is a tricky business, due to alignments and bitfield packing. It is so tricky that the compiler will generate this info into the file. class-dump-z will read from that part of memory and give the most correct result. Struct name prettifying
class-dump-z will typedef structs and unions to the most presentable name with heuristics. This feature can be explicitly turned off with the -N switch. Stable name generation for anonymous structs
Ever tried to diff a library between two versions? You'll be frustrated by so many differences that are caused by a change of indices in anonymous structs. No more problem in class-dump-z — as long as the struct is having the same members, the generated name will be fixed. The name is computed by the CRC-32 checksum of the Objective-C type encoding of the struct. Properties
class-dump-z supports declared properties. Not only that, it supports every property attributes, including the undocumented ones. Moreover, it will hide the extra copy of getters/setters if a property is present. PropertizationSome libraries are written before the dot syntax was introduced or by some dot-syntax-haters, so you'll see a long list of getters/setters like -(void)setTitle:(id)title; -(id)title; -(void)setSubtitle:(id)subtitle; -(id)subtitle; ... I found it pretty annoying. In class-dump-z you can supply the -p switch to automatically convert them into @property(retain) id title; @property(retain) id subtitle; ... Hide inherited and delegate methods@interface UITableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
int _tableViewStyle;
id _keyboardSupport;
}
@property(retain, nonatomic) UITableView* tableView;
// inherited: -(id)init;
-(id)initWithStyle:(int)style;
// inherited: -(void)dealloc;
-(id)existingTableView;
// declared property getter: -(id)tableView;
// declared property setter: -(void)setTableView:(id)view;
// inherited: -(void)loadView;
// inherited: -(void)viewWillAppear:(BOOL)view;
// inherited: -(void)viewWillDisappear:(BOOL)view;
// inherited: -(void)viewDidAppear:(BOOL)view;
-(void)setEditing:(BOOL)editing animated:(BOOL)animated;
-(void)_adjustTableForKeyboardInfo:(id)keyboardInfo;
// in a protocol: -(int)tableView:(id)view numberOfRowsInSection:(int)section;
// in a protocol: -(id)tableView:(id)view cellForRowAtIndexPath:(id)indexPath;
// in a protocol: -(void)tableView:(id)view willBeginEditingRowAtIndexPath:(id)indexPath;
// in a protocol: -(void)tableView:(id)view didEndEditingRowAtIndexPath:(id)indexPath;
@endMethod overloading in subclass is very common in OO design, but such information is useless when generating headers. Yet, by default a class dumper wouldn't know if an implementation is overloaded or a new method. If it's not useful, why not hide them? class-dump-z does that. Another class of useless information are those being implemented to adopt a protocol. class-dump-z can also filter them out. If you are running class-dump-z outside of the iPhoneOS, or you haven't installed the SDK, you have to tell class-dump-z where can the libraries be found by the -y switch. If you using using firmware 3.1, because all framework binaries are removed, hiding inherited methods from external frameworks won't work properly. Readable argument names
No more meaningless fpXX. class-dump-z will give a suitable name to each argument using Apple's coding style guide. Correct header generation
The headers generated by -H are not immediately usable because the imports usually points to non-existing .h files. There is even a page dedicated to fixing this problem. class-dump-z now will see which library the external class comes from, and tries to make up a better .h file location to import. Even with this change, headers generated by class-dump-z is generally not immediately usable either. This is usually because of name clash with Foundation and CoreFoundation objects. Most of the cases supplying the -X NS,CF flag to filter them out is enough to fix it. Hints fileWhen an Objective-C source is compiled, the class name in a method will be stripped, so in the dump you'll get -(void)touchesBegan:(id)began withEvent:(id)event; instead of -(void)touchesBegan:(NSSet*)began withEvent:(UIEvent*)event; Hints file is created to address this problem. When you pass the -i flag, a tab-delimited file will be created, which contains the type signature e.g. -[UIGestureRecognizer touchesBegan:withEvent:] void id id You can edit this file and change to the more precise signature, i.e. -[UIGestureRecognizer touchesBegan:withEvent:] void NSSet* UIEvent* then feed the same file with the -i flag. The updated signature will be reflected in the dump. Miscellaneous features
What's missingThere are some features I don't find them immediately useful, so they are not supported yet. Sort by inheritance (-I flag), Recursive dumping (-r)These are not easy to implement and I find them not so useful so I left them out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This is FANTASTIC!
Much Appreciated. Keep up the good work.
-Max
Great tool. Thanks for your work!
Skomski
I love it!
Hi kenny I get garbage for a llot of methods in ChatKit?. example:
@interface mSMSSendButtonView : XXUnknownSuperclass { } -(BOOL)Îúíþ; -(void)Îúíþ; -(float)Îúíþ; @end @interface CKSimpleBalloonView : CKBalloonView { NSString* _text; } +(float)minimumBubbleHeight; +(float)heightForText:(id)text width:(float)width includeBuffers:(BOOL)buffers; +(BOOL)showsSubject; -(id)Îúíþ; -(id)Îúíþ; -(void)Îúíþ; -(void)setMessagePart:(id)part; -(void)setComposition:(id)composition; -(void)Îúíþ; -(void)Îúíþ; -(void)Îúíþ; -(CGRect)subjectBounds; -(CGRect)textBounds; -(void)Îúíþ; @endare you awareof it?
Well done Kenny. I'll definitely prefer class-dummp-z than class-dumm-x or other.
Great work!
lovely work
Perfect work
Awesome.
Many thanks.
Running under OS X 10.6.8 on 32-bit intel core duo, /System/Library/Frameworks/CoreData?.framework/Versions/Current/CoreData? produces very little output, just the comment that would come at the start, saying Source: (null); whereas class-dump produces reasonable looking and fairly large output. Same also with Foundation. This is with no command line arguments, just the executable class-dump-z and the name of the Mach-O file. With either 0.2-0 or 0.2a, mac_x86. ?? Probably something obvious but I don't see it. I downloaded the source and presumably can figure it out if there's time. Thanks.
I am also getting the same error on both Windows 7 64-bit, and Mac OS X Lion 10.6.8. I am not sure how to fix this problem. I was simply trying to run "class-dump-z my.app", I also tried it with various command line arguments, but the result it always the same. Any ideas?
Here are you a script to automitize the recursive dump with class-dump-z Just change the path of the framework in the var FPATH, to make it more elegant you can pass it as a input parameter
Authors
@loretoparisi @christian_zanin
clear FPATH=/Applications/Xcode45-DP2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/ ROOTFOLDER=iPhoneOS6.0.sdk if -d $ROOTFOLDER
fi mkdir $ROOTFOLDER COUNTEXT="$(ls -l $FPATH | wc -l)" echo "All frameworks are $COUNTEXT"COUNT=0 for r in $(find $FPATH -maxdepth 1 -type d -exec ls -l "{}" \;| grep '\-rwxr\-xr\-x' | awk '{ print $9 }')
echo "Frameworks are $COUNT"Hi I am getting this error in my ipad dyld: Library not loaded: /usr/lib/libpcre.0.dylib
Trace/BPT trap: 5