Tim Dietrich

Custom Software Developer

Home Services Portfolio Blog About Contact Newsletter

Viewpoint: An Apple TV App Server

Most of the work that I'm doing these days involves development of Apple TV apps. While I've developed a few of them using the "native" development approach (where the app is written in Swift), I'm primarily using the client-server ("TVML") approach.

One of the challenges that I've been facing is hosting the application assets (including the TVML, TVJS, images, audio files, and so on). I've been hosting them with shared web hosting services, which for the most part has been working well. However, I would much prefer to host the assets in a way that gives me more control, better performance, and a high level of reliability.

I recently worked on a project called Luna, an open source framework for creating RESTful APIs. I developed it using the popular Xojo cross-platform development environment. Developing Luna was a lot of fun and extremely rewarding. The APIs that I've developed with it are extremely fast, reliable, and easy to maintain.

That got me thinking about my Apple TV hosting needs, and whether it might be possible to develop a solution in Xojo. I spent the better part of yesterday exploring the idea, and with the help of my good friend Hal Gumbert, I was able to put something together very quickly.

Introducing "Viewpoint"

The result is something that I'm calling Viewpoint. It's an Apple TV application server, which serves up both static files and dynamically generated TVML and TVJS templates.

I developed Viewpoint as a Xojo Web application. Before deploying it, it must first be compiled. And one of the benefits of it being a native, compiled app is that its speed is absolutely remarkable.

Minimizing Recompilation

When creating Viewpoint, one of my design goals was to avoid the need to recompile the app as much as possible.

I achieved that by adding support for a "static-content" folder, which is located in the same folder as the compiled app itself. To add a new static file to the Apple TV app, you simply place the file in the static-content folder and it is immediately available. You can also use sub-folders, so you can keep everything as organized as you'd like.

Dynamic Content With the Power of Xojo

When adding support for dynamic content, you have the full power of the Xojo programming language at your disposal - including any Xojo plug-ins that you'd like to use. To add a new dynamic file, you simply add a new method to the Web app. Viewpoint identifies requests for dynamic content by looking for the "dtvml" file extension. For example, a request for a dynamic TVML template might look: http://127.0.0.1/SampleAlert.dtvml

Logging

Viewpoint also includes a simple, but effective, logging function. Every request is logged to text files in a "server-logs" folder. A separate log file is created for each day.

Going to Production

I'm excited to be submitting my first Viewpoint-hosted Apple TV app to Apple this week. For this app, the Viewpoint instance will be hosted on a low-cost, Linux-based Amazon EC2 server.

I'll write more about Viewpoint in the weeks ahead. In the meantime, feel free to reach out to me if you need help developing an Apple TV app.