简介
class-dump is a command-line utility for examining the Objective-C segment of Mach-O files. It generates declarations for the classes, categories and protocols. This is the same information provided by using 'otool -ov', but presented as normal Objective-C declarations.
这是class-dump的官方解释,我们用的最多就是做iOS的逆向工程。class-dump,是可以把Objective-C运行时的声明的信息导出来的工具。其实就是可以导出.h文件。用class-dump可以把未经加密的app的头文件导出来。
官方网址:http://stevenygard.com/projects/class-dump/
安装
class-dump的下载地址:http://stevenygard.com/download/class-dump-3.5.tar.gz
点击下载后解压后会有class-dump和源码文件。将class-dump 复制到/usr/bin/class-dump。如果是OS X 10.11,因为没有/usr/bin文件夹的写权限,所以将class-dump复制到/usr/local/bin/class-dump即可。
同时打开Terminal,执行命令赋予其执行权限:
sudo chmod 777 /usr/bin/class-dump
使用
使用class-dump导出头文件的命令格式:
class-dump -H 需要导出的框架路径 -o 导出的头文件存放路径
示例:导出Xcode中DVTKit框架的头文件
1)找到DVTKit框架路径
2)使用上述的操作命令格式
附录
class-dump AppKit:
class-dump /System/Library/Frameworks/AppKit.framework
class-dump UIKit:
class-dump /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/UIKit.framework
class-dump UIKit and all the frameworks it uses:
class-dump /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/UIKit.framework -r --sdk-ios 4.3
class-dump UIKit (and all the frameworks it uses) from developer tools that have been installed in /Dev42 instead of /Developer:
class-dump /Dev42/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/UIKit.framework -r --sdk-root /Dev42/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
以上就是安装并使用class-dump的全部过程,希望对大家有所帮助。