Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a complete class-dump of Xcode, ready for adding to an empty Xcode project for all your header-ogling needs.
#!/bin/bash
# Creates a complete class-dump of Xcode and all its libs and internal plug-ins.
# Assumes you have Class-Dump in your path and Xcode at the location set via `xcode-select`.
xcodeClassDump=${1:-"$HOME/Documents/XcodeClassDump"}
xcodePath=`xcode-select -p`
sourceXcodeRootPath="$(dirname "$xcodePath")"
echo "Dumping from Xcode: $sourceXcodeRootPath"
echo "Creating dump in $xcodeClassDump"
# We need to `cd` into the directory, because we remove paths containing ".app" below and this would otherwise filter out everything contained in "Xcode.app".
cd "$sourceXcodeRootPath"
# Find all libraries and plug-ins within Xcode.app/Contents and call class-dump
# on each, preserving the folder structure in the output files.
# This will give many warnings like "doesn't contain an executable" or
# "Parsing method types failed". But it will succeed much more than it fails.
find . \( -iname "*.framework" -or -iname *.ideplugin \) ! -ipath *.platform* ! -ipath *.app* -print0 | xargs -0 -o -I % class-dump --arch x86_64 --sdk-mac -I -H -o "$xcodeClassDump/%" %
# Strip .framework and .ideplugin extensions from output folder names, so the
# files can be browsed more easily.
# (for example by adding the whole output folder to an empty Xcode project)
find "$xcodeClassDump" \( -iname "*.framework" -or -iname *.ideplugin \) -print | while read filename; do mv -v "$filename" "${filename%.*}"; done
@fzwo

This comment has been minimized.

Copy link
Owner Author

fzwo commented Oct 21, 2015

If you have any comments or improvements, I'm looking forward to your input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.