Thursday 6 September 2018

Record iOS App Flow on simulator apple script application

To show our App UI behaviour we generally use: 
1) App screen shots or
2) App flow recording.

App screenshot is easy to take as iPhone Simulator offer a simple way to capture a screenshot under the File tab (File -> Screen Shot) or cmnd+S.

To record app flow we generally use the QuickTime Player, select the area of simulator and start screens recording. For me, sometime it's hectic because it blocks that area of the screen to use for the system. If we use that area for any other window, that window will also record in recording, and we have to record our flow again. Don't you think it irritating?

So, Is it possible to record the simulator app flow without block of screen area? Yes, we can do that using a command line tool.

Screen simctl is a powerful command to control simulator using command line. So lets quickly record our app flow in the simulator.

open a terminal and write the following command:





Example:







It will start recording your simulator, now use your app so that flow can record.

Once you are done with app flow covered, press ctrl+C to stop recording. You recorded file will be saved at your defined path "/Users/username/Public/myAppFlow.mov".

Hope you enjoy it.

But, I am still not happy with it. The reason I am a lazy person, so I found it still painful to open terminal every time (if it's not open and open a new window or tab if it opened) and type the command and record it and then go to finder and see where is my recoding. 
In this case I mostly forgot to close the terminal after use it (You know I am a lazy person :))

So I like to automate or want an application that we can put in our dock and use it with one click for recording. What our app should do, let's create the use case and flow for that:

1: App should check if your simulator is open or not. 
2: If not opened, asked you to open the simulator first.
3: If the simulator is open, check for terminal is open or not 
4: If the terminal is not open, open new terminal window 
5: If the terminal is open already, open new tab in a terminal window so that previous running work does not effected.
6: Run the cmd line tool for video record.
7: User use app so it will record. Once you finish with app usage to record, There should be button to finish recording.
8: Close the terminal if we it was not previously launched.
9: Close the tab of terminal that we open for our command run.
10: Open the video recorded path in finder with the Default Quicktime player to view what we recorded.


To create such app for MacBook, Apple provides serious way. You can use Mac App using Xcode, can create Automator workflow or you can write and apple script application. I would prefer apple script for this type of App. Here is the Code for above mentioned use cases covered script. You can find code here on github project Simulator_record_script.


If you, new to Apple script, you can get some help with my previous Tutorial on apple script. 

So now, we have done with the Apple script code. Lets Export it as an application.
You can download it from here . 

It will show you warning that it harm your computer as it a script application. So you can goto my github project  and download the code source file open it in apple script editor. Once you feel it not have any privacy breaking code you can also export it as application and use it.

Put it in your dock and use for easy video recording of app flow in the simulator for your usage (client demo, GIF from video for GitHub repo, bug discussion of UI flow etc.)

Hope you enjoy it and it helps you in your work.