陈斌彬的技术博客

Stay foolish,stay hungry

Objective-C Class-dump 安装和使用方法(原创)

class-dump is a command-line utility for examining the Objective-Csegment of Mach-O files. It generates declarations for the classes,categories and protocols. This is the same information provided byusing ‘otool -ov’, but presented as normal Objective-C declarations.

1.下载安装包

http://stevenygard.com/projects/class-dump/
这里我下载的是 class-dump-3.5.dmp。然后把 img放到/usr/local/bin目录下, 在终端输入 class-dump,显示 class-dump的版本后,就可以正常使用 class-dump 命令了。 正确安装后如下图所示:

img

2.使用方法

命令如下:class-dump -H /Applications/Calculator.app -o /Users/apple/Desktop/calculate\ heads

解释:
/Applications/Calculator.app是计算器app的路径
/Users/apple/Desktop/calculate\ heads 是存放dump出来头文件的文件夹路径

结果如下:

img

利用 class-dump 可以导出 AppKit,UIKit。。。

class-dump AppKit:class-dump /System/Library/Frameworks/AppKit.framework

class-dump UIKit: class-dump /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework