Month: November 2016

Over the weekend I finally got time to work on something I’ve been meaning to get round to for quite some time now.

Introducing ShowTime, an insanely simple way to show your taps and gestures while demoing your iOS app.

Why another one?

I know, if you Google “show touches iOS app” you’ll get a few results. Some old with no recent support and some newer with some support. The reason I still decided to make ShowTime is because none of the solutions I’ve tried work with both single- and multi-window iOS apps.

The last two projects I’ve inherited at work both display new content in multiple windows. This would mean replacing each window with one of the “show touches” window solutions, which isn’t a trivial amount of work.

No, what I want is something that has little to no set up whatsoever, works with multiple windows automatically and can show the level of pressure shown on devices that support 3D Touch. Oh and it needs to be pure Swift code.

So I made one myself.

Why show touches on screen?

If you’re watching someone use an app on their phone, you can see what their fingers are doing so the gestures make sense. In contrast, if you’re watching someone use an app on a screen or video without being able to see their hands, you suddenly loose a lot of context, especially around multiple-touch gestures.

We work hard on making apps, and demoing them is part of our job as professional developers. As an iOS developer we don’t have a native way of showing touches on screen like Android do, so we have to get creative.

How does it work?

ShowTime uses method swizzling, a technique used to replace a default implementation of a class’ function with your own. Swift itself doesn’t support method swizzling, but because any Swift type that inherits from NSObject uses the Obj-C runtime, it is possible to swizzle their methods.

Thankfully, UIWindow inherits from NSObject so it’s possible to swizzle its methods, and the one we’re specifically interested in is sendEvent(_:) which takes a UIEvent as its argument.

ShowTime replaces the default sendEvent(_:) method with its own, and intercepts the event to extract touches. It then displays those touches on the window receiving sendEvent(_:) and then lets the window carry out its default implementation of sendEvent(_:).

This means that all instances of UIWindow (and its subclasses) will automatically get this behaviour, so it doesn’t matter if new windows are created, touches will always be shown.

How to set up ShowTime

There’s actually nothing to do to set up ShowTime other than to include ShowTime.swift in your project.

That said, you can customise the behaviour if you want. You can change the fill and outline of each visual touch, whether force is shown visually, whether to include the number of taps inside each visual touch (great for demoing maps), and more. By default ShowTime shows a blue visual touch, because it contrasts well with most content.

My recommendation for keeping ShowTime around without putting it into production code is to create a demo branch in your repo which has ShowTime installed. You can then merge develop into this branch whenever you’re demoing something, and because there’s such little setup with ShowTime you’ll rarely get merge conflicts.

Hopefully you’ll try ShowTime during your next client demo, internal demo or while creating a product video. If you do, please let me know how you get on!