November 4, 2018

Building a workout timer as an iOS Shortcut

Get Shortcut.

With the release of iOS 12 with Shortcuts, I get the feeling many simple utility apps will soon be obsolete.

Websites like ShortcutsGallery.com host communities of people sharing free shortcuts to translate text, look up the weather, or split a bill—tasks currently handled by hundreds of App Store apps. Apple is headed for a world where it provides all the feature-rich building blocks (maps, photo manipulation, communications, etc) so that you never need to leave the Apple ecosystem. As a user, I’m all for it—it’s an especially good user experience when it’s all voice controlled with Siri, avoiding the need to even look at a screen.

I recently tried to find a workout timer app for the type of workout I like to do, but the four or five free apps I tried either didn’t do what I wanted, or asked for payment after 20 minutes. So I decided to build my own using an iOS Shortcut. It counts down through a series of exercises and Siri announces each new section.

It’s pretty tailored to my specific routine, and it relies on me knowing what each exercise name actually means, but it works really well.

Features

  • Provides a menu to choose which areas to work out (upper body, legs, core)
  • For each area, cycle through five exercises: two rounds at slow pace, then a final round at fast pace
  • Siri announces each step, and it works over music
  • Logs the workout to the Health app

Clunky stuff when building a shortcut

Some of the programming” patterns in the Shortcuts were not immediately obvious to me:

  • Setting a variable. I thought the Set variable” action would let me choose a value to store in it, but it actually just stores whatever it receives as input. That means if you want to store a number, you first add a Number” action to produce the number, then add the Set variable” action to store it.
  • Similarly, when you want to consume a variable in an action, you also need to make sure it’s being fed in as input. You use the Get variable” action to do this.
  • There’s no way to insert an action at a particular point in the workflow, so I spent a bit of time dragging actions from the bottom of the list up to where they needed to be.
  • If you Speak text” with Siri, and don’t choose the Wait until finished” option, and try to speak more text before the first is done, the shortcut will crash.
  • You can’t pause a shortcut, which means you really have to commit to the workout.

Future features

  • Add more exercises to each category, and randomly choose five of them each time
  • Display a preview of the workout before starting
  • Add some better sounds for starting and finishing
  • Add sounds to count down the last few seconds of each exercise

iOS Shortcuts iOS


Previous post
How does Monaco Editor enable text editing on a web page?
Next post
How to forward emails via Zapier to create new contacts in Airtable