Inspect and adjust any app in real time
There aren’t many times outside of WWDC where Apple developers see a new tool and immediately think “I need that in my life.” Sherlock by Inspired Code is one such tool: it injects itself into the iOS Simulator so that it can monitor views and adjust them in real time.
If you aren’t already thinking you need that, let me rephrase what I just said: you can inspect any app in the simulator, including system apps, see how they were built, and dynamically change large parts of them. Want to adjust the way image views fit their images, how text is aligned, or what background color is used? Sherlock does all those things and more – you just select the thing you want to change and click away until you’re happy.
Introducing Sherlock: Give your iOS Simulator superpowers! Edit views in real time, see what your app looks like on other devices and more, with zero setup required! pic.twitter.com/XLy01rzGMr— Sherlock by InspiredCode (@getsherlockapp) September 21, 2018
When working with one of your own apps, Sherlock provides an unparalleled ability to experiment: navigate your way through your view hierarchy, select something you want to work with, then adjust any number of settings right from a macOS window. And when you want to compare your changes to the code, there’s even a “Jump to File” button that takes you straight there.
Even more impressively, you can attach a resizable screen to any app, allowing you instantly flick between various common iOS device sizes: iPhone 5, 6, and X are all available. Selecting a size immediately updates the layout to how it would look on the new device – it’s not just stretched to fit.
Right now the app is available as a free beta, so there really is no reason not to give it a try. In the future it would be great to see even more view properties exposed, and in particular the ability to visualize and dynamically adjust Auto Layout constraints would be particularly useful. Of course, it’s hard to be too demanding – Sherlock only just launched, so for it to be so impressive out of the box is quite remarkable.
Sherlock is being developed by Samuel Stone and Jake Lawson, and Sam was kind enough to take the time to answer a few questions about their motivations and plans, and even a little about it works.
Hacking with Swift: What was your inspiration for creating Sherlock?
Samuel Stone: Primarily, the amount of time we were wasting.
We both work on pretty large apps with a lot of nested screens, and a fairly involved process to onboard a new device, so we were burning a lot of time testing out design tweaks, rebuilding every time and then having to switch between simulators to confirm that the layout worked on all device types.
Similarly, we’d often find ourselves working on unfamiliar screens, wanting to know what UIViews and UIViewControllers we were actually looking at, and having to pause and unpause the app to confirm in Xcode’s visual debugger was frustrating.
HWS: Are there more features you're working on for the next release?
SS: Our focus at the moment is on making the existing features work as well as possible. Right now, that includes expanding the range of inspectable properties and making the Jump to File feature faster and more reliable for larger codebases.
Longer term, we’ve got a lot of ideas for exciting new features, such as a way to undo changes, or to have changes automatically reflected in your storyboards, but which ones actually make it into the app will depend on whether we can get them working in a reliable and consistent way.
HWS: The question many people will be asking is “how does it work?” What can you tell us?
SS: The Objective-C runtime and a lot of black magic.
Sherlock works in much the same way as Reveal or Xcode’s own visual debugger works - it loads a library into the target app to expose a way for other processes to interact with it.
It also uses some extra magic to inject itself without requiring any configuration by making use of the same sort of techniques that Xcode itself uses to speak to the Simulators.
HWS: Given its history in the Apple world, why did you choose the name “Sherlock”?
SS: Because we think it’s super smart, and using Sherlock is like having a detective for your app!
Regarding the history of the name, we knew a lot of people would comment on it, but that just made us like it even more.
And in the end, if Apple does decide to sherlock Sherlock, that’s not the worst thing that could happen. They’re the best positioned people to build something like this, so if they did it would be a big win for iOS developers in general.
Paul Hudson is the creator of Hacking with Swift, the most comprehensive series of Swift books in the world. He's also the editor of Swift Developer News, the maintainer of the Swift Knowledge Base, and a speaker at Swift events around the world. If you're curious you can learn more here.