简介
class-dump是用来dump目标文件的类信息的工具。它利用Objective-C语言的runtime的特性,将存储在Mach-O文件中的@interface和@protocol信息提取出来,并生成对应的.h文件
安装
下载地址:class-dump-3.5.dmg
将dmg文件中的class-dump复制到/usr/local/bin目录,并在终端执行如下执行进行赋权:
sudo chmod 777 /usr/local/bin/class-dump
然后运行class-dump
~ class-dump
class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48)
Usage: class-dump [options] <mach-o-file>
where options are:
-a show instance variable offsets
-A show implementation addresses
--arch <arch> choose a specific architecture from a universal binary (ppc, ppc64, i386, x86_64, armv6, armv7, armv7s, arm64)
-C <regex> only display classes matching regular expression
-f <str> find string in method name
-H generate header files in current directory, or directory specified with -o
-I sort classes, categories, and protocols by inheritance (overrides -s)
-o <dir> output directory used for -H
-r recursively expand frameworks and fixed VM shared libraries
-s sort classes and categories by name
-S sort methods by name
-t suppress header in output, for testing
--list-arches list the arches in the file, then exit
--sdk-ios specify iOS SDK version (will look for /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk
or /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk)
--sdk-mac specify Mac OS X version (will look for /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX<version>.sdk
or /Developer/SDKs/MacOSX<version>.sdk)
--sdk-root specify the full SDK root path (or use --sdk-ios/--sdk-mac for a shortcut)
使用class-dump
class-dump -H [MachO文件路径] -o [存放dump结果的头文件文件夹路径]
-H
表示要生成头文件
-o
用于制定头文件的存放目录