Skip to content

Instantly share code, notes, and snippets.

@raven
Last active August 30, 2019 00:53
Show Gist options
  • Save raven/8553761 to your computer and use it in GitHub Desktop.
Save raven/8553761 to your computer and use it in GitHub Desktop.
Symbolic breakpoint for dynamically linking libReveal against UIApplicationMain

The laziest way to have Reveal available for all of your projects, without touching any source code

With the power of Xcode's symbolic User breakpoints, you can easily toggle on and off dynamically linking Reveal into your app.

The lazy way

Warning: This does not affect your current project or workspace breakpoints but will blast away any User breakpoints.

  1. Quit Xcode, and in terminal:
mkdir -p ~/Library/Developer/Xcode/UserData/xcdebugger && curl https://gist.githubusercontent.com/raven/8553761/raw/Breakpoints_v2.xcbkptlist -o ~/Library/Developer/Xcode/UserData/xcdebugger/Breakpoints_v2.xcbkptlist

Thats it, you're done.

Open any Xcode project and you will see in your breakpoint navigator a breakpoint that you can toggle on and off as you see fit.

breakpoint

Note: also make sure breakpoints are enabled for blue breakpoint goodness

global breakpoints


What's happening here?

  1. Xcode's User breakpoints are kept in ~/Library/Developer/Xcode/UserData/xcdebugger, so the above script creates that directory if it does not exist.
  2. Then the script downloads the above xml file, Breakpoints_v2.xcbkptlist and drops it in the xcdebugger directory (will overwrite any existing breakpoint file if one already existed).
  3. Breakpoint files in this directory are known as User breakpoints, and are available across all of your projects. The great thing is that they don't interfere with any project files, or source files.
  4. This xml describes a Symbolic breakpoint, that will issue a lldb command on every UIApplicationMain, and continue execution after running the command.
  5. The command that is issued is executes dlopen, and dynamically links the libReveal.dylib at runtime into your application. This command will need to be edited if Reveal.app does not live in your /Applications directory
  6. Once your run your app, the breakpoint gets fired once code enters UIApplication main, and libReveal is linked. Within libReveal, a +load method sets up the listeners to start the server once UIApplicationDidBecomeActiveNotification has been fired to the notification center.

The long way a.k.a. I don't paste things from the Internet into my terminal

  1. Open the Breakpoint navigator in Xcode, and hit the '+' down the bottom and create new Symbolic Breakpoint
    Symbolic Breakpoint
  2. Set the symbol to UIApplicationMain, add action and set to Debugger Command, add the command expr (void*)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);, and tick Automatically continue after breaking config breakpoint
  3. Then right click the break point, and select Move Breakpoint To > User move breakpoint to user
  4. That's it. You should now see across all of your projects in the breakpoint navigator the User breakpoint breakpoint

All of the above only works for Simulator Only, for ways to do this on device, read Oliver's post Integrating Reveal without modifying your Xcode project

We are constantly looking at ways to ease the integration process of Reveal into your debug workflow. Any comments, shoot to @peterngoldsmith or @reveal_app

<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "Yes"
symbolName = "UIApplicationMain"
moduleName = "">
<Actions>
<BreakpointActionProxy
ActionExtensionID = "Xcode.BreakpointAction.DebuggerCommand">
<ActionContent
consoleCommand = "expr (void*)dlopen(&quot;/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib&quot;, 0x2);">
</ActionContent>
</BreakpointActionProxy>
</Actions>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
@Ashton-W
Copy link

The Lazy Way didn't work for me.

@RoCry
Copy link

RoCry commented Mar 27, 2014

@Ashton-W

try this

mkdir -p ~/Library/Developer/Xcode/UserData/xcdebugger && curl https://gist.githubusercontent.com/raven/8553761/raw/df3f6a5055052c27e91928382827b6b8bdaacc55/Breakpoints_v2.xcbkptlist -o ~/Library/Developer/Xcode/UserData/xcdebugger/Breakpoints_v2.xcbkptlist

I don't know why the raw url of the gist in the article is wrong...

@0oneo
Copy link

0oneo commented Apr 4, 2014

nice, works for me, 3ks a lot

@xhzengAIB
Copy link

Hi! @raven
I have simulator in the pass Reveal app can't see the connection.
Can you help me?

Jack

@raven
Copy link
Author

raven commented May 9, 2014

@RoCry thanks, github has since changed the raw link handling. Fixed with https://gist.githubusercontent.com/raven/8553761/raw/Breakpoints_v2.xcbkptlist

@variyty123
Copy link

2019 you guys commented when i was in kinder garden

@variyty123
Copy link

2014*

@variyty123
Copy link

im 10 years old now

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