class-dump:用来dump目标文件的class信息的工具。它利用Objective-C语言的runtime的特性,将存储在mach-O文件中的@interface和@protocol信息提取出来,并生成对应的.h文件。
1、下载地址:
http://stevenygard.com/projects/class-dump/
2、打开终端输入
wifi:~ clf$ open /usr/local/bin
3、把dmg文件中的class-dump文件复制到/usr/local/bin
4、赋予其执行权限权限:终端输入
wifi:~ clf$ sudo chmod 777 /usr/local/bin/class-dump
5、运行class-dump,可以看到它的一些基本参数
wifi:~ clf$ class-dump
class-dump 3.5 (64 bit)
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 in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk
--sdk-mac specify Mac OS X version (will look in /Developer/SDKs/MacOSX<version>.sdk
--sdk-root specify the full SDK root path (or use --sdk-ios/--sdk-mac for a shortcut)
class-dump的对象是Mach-O格式的二进制文件
class-dump使用
class-dump -S -s -H 可执行文件路径 -o 获取到头文件存放路径
wifi:Documents clf$ class-dump -S -s -H /Users/ppd/Documents/TargetApp.decrypted -o /Users/ppd/Documents/TargetApp
错误集:
wifi:~ clf$ class-dump -S -s -H /Users/clf/Desktop/breakApp/HBchannel/TargetApp.decrypted -o /Users/clf/Desktop/breakApp/HBchannel/headers
2018-01-24 14:41:03.632 class-dump[1206:394495] Error: Cannot find offset for address 0x1800000001003c7a in stringAtAddress:
原因:经检验和查看该项目是用OC和Swift混编。class-dump是利用Object-C语言的runtime特性,提取头文件,而Swift则不支持该规则。
网友评论