Skip to content

Instantly share code, notes, and snippets.

@Ashton-W
Last active December 13, 2020 02:28
Show Gist options
  • Save Ashton-W/6db611ac93be2f8bad7f to your computer and use it in GitHub Desktop.
Save Ashton-W/6db611ac93be2f8bad7f to your computer and use it in GitHub Desktop.
Build Phase Script for copying and signing libReveal in Debug Configuration
#!/usr/bin/env bash
# Build Phase Script for copying and signing libReveal based on Configuration
# https://gist.github.com/Ashton-W/6db611ac93be2f8bad7f
set -o errexit
set -o nounset
LIBREVEAL_PATH="/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib"
INJECT_REVEAL="${INJECT_REVEAL:-NO}"
#
copy_library() {
cp -vRf "$LIBREVEAL_PATH" "${CODESIGNING_FOLDER_PATH}/libReveal.dylib"
}
#
codesign_library() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" ]; then
codesign -fs "${EXPANDED_CODE_SIGN_IDENTITY}" "${CODESIGNING_FOLDER_PATH}/libReveal.dylib"
fi
}
#
main() {
if [ "${INJECT_REVEAL}" == "YES" ]; then
if [ -e $LIBREVEAL_PATH ]; then
copy_library && codesign_library
echo "Reveal library copied (INJECT_REVEAL=YES)"
else
echo "Reveal library not found at: $LIBREVEAL_PATH"
echo "set LIBREVEAL_PATH to correct"
fi
else
echo "Did not copy Reveal library (Build Setting INJECT_REVEAL=NO or not set)"
fi
}
main
@Ashton-W
Copy link
Author

Ashton-W commented Oct 22, 2015

Add a Run Script Build Phase that calls this script.

Adding the Build Phase script

Add a user define Build Setting to enable Reveal injection for certain targets (eg: Debug)

Adding the Build Setting

Click the ➕ button at the top of the Build Settings list.

@Ashton-W
Copy link
Author

A symbolic breakpoint on UIApplicationMain with the following Debugger Command Action will load Reveal from inside the app.

expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen([[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"].UTF8String, 0x2) : ((void*)0)

screencapture at 22-10-2015-20_59_26

Alternatively, follow the code sample from the official Reveal Integration Guide, see Dynamic Loading.

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