Skip to content

Instantly share code, notes, and snippets.

@JanX2
Forked from fzwo/xcode-class-dump.sh
Last active April 10, 2016 08:34
Show Gist options
  • Save JanX2/07788c3654a4984088926065ed4aaa26 to your computer and use it in GitHub Desktop.
Save JanX2/07788c3654a4984088926065ed4aaa26 to your computer and use it in GitHub Desktop.
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
Copy link

fzwo commented Apr 9, 2016

This looks like a nice update to my crude script. It's still not possible to open a pull request on a gist, right? I'll merge your changes into my gist this weekend.

@fzwo
Copy link

fzwo commented Apr 10, 2016

Merged your fork. Thank you for the improvements!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment