Skip to content

Instantly share code, notes, and snippets.

@0xced
Last active November 1, 2018 14:56
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save 0xced/5010019 to your computer and use it in GitHub Desktop.
Save 0xced/5010019 to your computer and use it in GitHub Desktop.
How to class-dump an iOS static framework

Using HockeySDK as an example

  1. Download HockeySDK 3.0.0
  2. Run these commands:
ARCH=armv7
FRAMEWORK_DIRECTORY="${HOME}/Downloads/HockeySDK-iOS-3/HockeySDK.embeddedframework"
FRAMEWORK_NAME=$(basename `echo "${FRAMEWORK_DIRECTORY}"/*.framework` .framework)

if [[ ${ARCH} == arm* ]]; then
    PLATFORM=iPhoneOS
    VERSION_MIN_FLAG='-miphoneos-version-min'
else
    PLATFORM=iPhoneSimulator
    VERSION_MIN_FLAG='-mios-simulator-version-min'
fi

SDK_DIR=`xcode-select -print-path`/Platforms/${PLATFORM}.platform/Developer/SDKs
SDK=$(ls "${SDK_DIR}" | tail -n 1)
SDK_VERSION=$(basename ${SDK} .sdk | grep -o [0-9.]+)

echo "int main(int argc, char *argv[]) { return 0; }" | clang -x c -arch ${ARCH} -ObjC -flat_namespace -undefined suppress -isysroot "${SDK_DIR}/${SDK}" "${VERSION_MIN_FLAG}=${SDK_VERSION}" -Xlinker -objc_abi_version -Xlinker 2 -F"${FRAMEWORK_DIRECTORY}" -framework "${FRAMEWORK_NAME}" -o "${TMPDIR}/${FRAMEWORK_NAME}" - && class-dump "${TMPDIR}/${FRAMEWORK_NAME}"
@smbhuin
Copy link

smbhuin commented Oct 30, 2014

whenever executing this script its throwing below error:

ld: warning: -ios_version_min not specified, assuming 6.0
ld: file not found: /usr/lib/libFosl_dynamic.dylib for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do you know how to fix this issue?

Thank you.

@amitu
Copy link

amitu commented Dec 31, 2014

@5mb, were you able to find a solution for this? I am facing a same error in unrelated project.

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