RecordScreen.start()

Table of Contents

At Lambda, we recently had a build week, which essentially boils down to getting some real world simulated experience where we work with a team consisting of students from a few of the disciplines taught at Lambda. My team had a couple web front ends, a couple web UI developers, a UX designer, a back end developer, myself (iOS dev, duh), and our team lead.

After the project is over, we not only got our experience, we were left with a not-unsubstantial portfolio piece, demonstrating our success in working together as well as features that require multiple working pieces, which means that my app relies on having a functioning back end. Since I have no control over whether our team back end maintains the server (nor am I fluent in how he set it up), I want to have continual proof that my app worked and worked well.

Simulated Time Travel

While the app works as of this writing, there’s no guarantee it’ll continue to do so. And if it stops (and since time travel to a time when the app works[ed] isn’t currently possible) the best alternative is to record some screen capture, demonstrating its features. The obvious answer is to use QuickTime (or an AirPlay server) to record my real device, but I have an iPhone 6S, and the app just looks better on a larger screen than mine and portfolios are all about showcasing your best work! That would mean that my only option is to record on the simulator… But wait – the simulator doesn’t support casting to AirPlay, nor is there a record option.

OR IS THERE?!

There is! It’s just hidden behind the glow of the Terminal.

  1. If you have more than one simulated device open, close all but the one you want to record.
  2. Stage your app/Simulator so it’s ready for recording
  3. In Terminal, navigate to a directory where you want to save the resulting file to
  4. Run
    • xcrun simctl io booted recordVideo [filenameNoBrackets.mp4]
  5. In Simulator, do whatever you want to demonstrate
  6. Back in Terminal, hit {ctrl}+{c}
    • Now you have an mp4 screen recording of your app demo!
  7. Open it somehow – open . will open the current directory, open [filenameNoBrackets.mp4] will open the file in the default player, or you can simply navigate to the directory in Finder and open it that way.

There’s Gotta Be a Catch

While this actually works pretty slick, there are a few caveats.

  • Just like recording a tethered device or over AirPlay, it doesn’t show where touches occur
    • The Fix: I used the Touch Visualizer framework to just show touches on screen, but only enabled it for the demo.
    • Alternative: As of this writing, this didn’t work for recordings, but defaults write com.apple.iphonesimulator ShowSingleTouches 1 shows touches on the Simulator screen. I believe it might have in the past, and perhaps will again in the future.
  • Nor does it curve the corners of beveled devices (like the iPhone X) and instead just leaves rectangular corners.
    • The Fix: If you care, you’ll need to run the file through a video editor and add the corner radius back in
  • Finally, the resulting file might be glitchy in certain circumstances – specifically, when I imported mine into FCP X to do some touch up editing, the decoding left smearing on the image.
    • The simple solution: Run the file through Handbrake on a high quality (exporting from QuickTime Player probably would work fine as well, but I prefer the quality, control, and speed of Handbrake).

Show Me an Example!

I thought you’d never ask! First, this is my project on GitHub, but specifically, here’s the demo video I recorded to preserve the proof of my app working.

Leave a Reply