Last active
December 13, 2020 02:28
-
-
Save Ashton-W/6db611ac93be2f8bad7f to your computer and use it in GitHub Desktop.
Build Phase Script for copying and signing libReveal in Debug Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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)
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
Add a Run Script Build Phase that calls this script.
Add a user define Build Setting to enable Reveal injection for certain targets (eg: Debug)
Click the ➕ button at the top of the Build Settings list.