Enabling Reveal on a running app in the simulator

Reveal is an amazingly useful weapon in my arsenal of development tools. It's simply the best thing around for diagnosing interface issues. The problem though is that up until recently we had setup a new target in XCode to use it. Oliver at Itty Bitty Apps did a great blog post about avoiding this by adding some commands to the LLVM debugger.

I followed his advice and it works really well. The basic procedure is

  1. Pause the app in the simulator.
  2. Install the Reveal library into the app being debugged using Oliver's reveal_load_sim debugger command.
  3. Start the Reveal server in the app using Oliver's reveal_start.
  4. Continue running the app.

At this point you can switch over to the Reveal OS X app and diagnose the interface of the app you are running.

I've been doing this for a while and was thinking - "Could I do this any easier?"

And here's what I came up with.

Using Reveal - the really quick way !

To do this we are going to make use of a another aspect of the debugger - it's ability to run scripts. Firstly, create a file to contain the script anywhere on your system. I created one called ~/continue-with-reveal in my home directory.

Now add these commands to it

expr (void*) dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
expr (void) [(NSNotificationCenter *)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
continue

Next we create a config file for the LLDB debugger and add this command alias to it

command alias reveal command source ~/continue-with-reveal

Thats all we need to do. Now the procedure becomes

  1. Pause the app in the simulator.
  2. Run reveal at the debugger command line.

The beauty of this version is that the script does 3 things - install the library, start the server and continue running the app.


Comments powered by Disqus