objc-class-tree can print a nice tree of Objective-C classes.
By default, it will print a huge tree of all the classes loaded in its own binary:
$ objc-class-tree | head -30
NSProxy
_NSZombie_
__NSMessageBuilder
__NSGenericDeallocHandler
Object
NSObject
βββ OCTMethod
βββ OCTTreeFormatter
βββ NSURLDownload
βββ NSXPCInterface
βββ NSAppleEventDescriptor
βββ NSFileWrapper
βΒ Β βββ NSFileWrapperLink
βΒ Β βββ NSFileWrapperDirectory
βΒ Β βββ NSFileWrapperFile
βββ NSURLSessionConfiguration
βββ NSSpellEngine
βββ NSXMLParser
βββ NSXMLNode
βΒ Β βββ NSXMLElement
βΒ Β βββ NSXMLDTDNode
βΒ Β βββ NSXMLDTD
βΒ Β βββ NSXMLDocument
βββ NSValueTransformer
βΒ Β βββ _NSSharedValueTransformer
βΒ Β Β Β βββ _NSUnarchiveFromDataTransformer
βΒ Β Β Β βββ _NSKeyedUnarchiveFromDataTransformer
βΒ Β Β Β βββ _NSNegateBooleanTransformer
βΒ Β Β Β Β Β βββ _NSIsNotNilTransformer
βΒ Β Β Β Β Β βββ _NSIsNilTransformer
$ objc-class-tree | wc -l
401
You can limit its output to a handful of class trees by using the --root-class option:
$ objc-class-tree --root-class NSArray --root-class NSXMLNode
NSArray
βββ NSKeyValueArray
βββ __NSOrderedSetArrayProxy
βββ __NSArrayI
βββ NSMutableArray
Β Β βββ NSKeyValueMutableArray
Β Β βΒ Β βββ NSKeyValueNotifyingMutableArray
Β Β βΒ Β βββ NSKeyValueIvarMutableArray
Β Β βΒ Β βββ NSKeyValueFastMutableArray
Β Β βΒ Β βΒ Β βββ NSKeyValueFastMutableArray2
Β Β βΒ Β βΒ Β βββ NSKeyValueFastMutableArray1
Β Β βΒ Β βββ NSKeyValueSlowMutableArray
Β Β βββ __NSPlaceholderArray
Β Β βββ __NSCFArray
NSXMLNode
βββ NSXMLElement
βββ NSXMLDTDNode
βββ NSXMLDTD
βββ NSXMLDocument
You can ask it to output implemented methods:
$ objc-class-tree --root-class NSURLResponse --methods
NSURLResponse
βββ - init
βββ - dealloc
βββ - copyWithZone:
βββ - initWithCoder:
βββ - encodeWithCoder:
βββ - URL
βββ - _CFURLResponse
βββ - _initWithCFURLResponse:
βββ - initWithURL:MIMEType:expectedContentLength:textEncodingName:
βββ - suggestedFilename
βββ - expectedContentLength
βββ - textEncodingName
βββ - MIMEType
βββ + _responseWithCFURLResponse:
βββ NSHTTPURLResponse
Β Β βββ - initWithCoder:
Β Β βββ - statusCode
Β Β βββ - _initWithCFURLResponse:
Β Β βββ - initWithURL:statusCode:HTTPVersion:headerFields:
Β Β βββ - initWithURL:statusCode:headerFields:requestTime:
Β Β βββ - _peerTrust
Β Β βββ - _setPeerTrust:
Β Β βββ - _clientCertificateState
Β Β βββ - _clientCertificateChain
Β Β βββ - _peerCertificateChain
Β Β βββ - allHeaderFields
Β Β βββ + supportsSecureCoding
Β Β βββ + isErrorStatusCode:
Β Β βββ + localizedStringForStatusCode:
It can also display protocols and which libraries the classes come from:
$ objc-class-tree --root-class NSString --protocols --library-names
NSString <NSCopying, NSMutableCopying, NSSecureCoding> (Foundation)
βββ NSSimpleCString (Foundation)
βΒ Β βββ NSConstantString (Foundation)
βββ NSPathStore2 (Foundation)
βββ NSLocalizableString <NSCoding, NSCopying> (Foundation)
βββ NSPlaceholderString (Foundation)
βββ NSMutableString (Foundation)
Β Β βββ NSPlaceholderMutableString (Foundation)
Β Β βββ NSMutableStringProxyForMutableAttributedString (Foundation)
Β Β βββ __NSCFString (CoreFoundation)
Β Β Β Β βββ __NSCFConstantString (CoreFoundation)
See main.m for more supported options.
Build using Meson as usual:
$ meson build
$ cd build
$ ninja build
# optionally
$ sudo ninja installobjc-class-tree is free software, available under the GNU General Public License version 3 or later.