What’s so different about tvOS? An iOS Developer’s Thoughts

Apple TV was one of the biggest announcements coming out of September’s Apple event, finally bringing to reality one of the Apple’s longest-tenured rumors. With the new Apple TV, Apple is allowing us to finally create our own apps using the brand new tvOS platform, opening up the Apple TV to developer apps in the same way that iOS and OSX have done. This provides an exciting new platform for both developers and consumers to reach their audience and provide new experiences for users.

The most important (and the most exciting) detail about the platform is that you can develop two different kinds of apps for Apple TV: ones utilizing native languages (like Objective-C or Swift) or by using Javascript. This opens up the Apple TV platform to more developers than ever before, making it easy for just about anyone to jump right in and create high-quality apps.

During this blog post I’ll review quickly what Apple announced for tvOS and share my first impressions about the new Apple TV after having spent some time playing around with the SDK.

What’s New?

For the most part, tvOS is inheriting a lot of frameworks from iOS; you can find the complete list here. For iOS developers, tvOS should feel very familiar, so let’s take a look at some of the new frameworks available for Apple TV that will not be as familiar.

Focus

With tvOS, developers and designers are facing a new challenge: navigating an app without touch input. We are accustomed to developing apps with open-ended interfaces, allowing the user to navigate as they please; with tvOS, however, we now have to change our thought-process to a more linear navigation, one where users can only move from element to element in a strict fashion. To resolve this major issue and provide a good user experience, Apple worked on a focus engine that will help users seamlessly navigate the different elements of your app.

The focus engine provides context for the user’s interaction by giving emphasis to elements that are currently in focus. It does this by zooming in and giving it feedback. Moving your finger on the remote touch pad will switch between focusable elements and tapping on the remote will perform an action, just like clicking a mouse or tapping a touchscreen.

new-apple-tv-4

Only specific elements are focusable where it makes sense to have an action when tapping:

  • UIButton
  • UIControl
  • UISegmentedControl
  • UITabBar
  • UITextField
  • UITableViewCell
  • UICollectionViewCell

For collection views and table views, you need to implement delegate methods to let the system know which cell is focusable using `canFocusItemAtIndexPath:`.

tvOS provides some APIs to know what element is currently focused and how to respond to focus updates. You can also tell the system which element should be focused first when pushing to the view so the user doesn’t have to scroll manually. For example, if you have a page containing a video with a play button, you probably will want to immediately focus on the play button when the page opens to let users start the video right away.

The focus engine doesn’t provide a default appearance for UICollectionView cells, so if your cell contains a UIImageView, you need to enable its default focus appearance:

imageView.adjustsImageWhenAncestorFocused = true

You can also tell the system which element should be focused first by requesting an update of the focus engine during the next update cycle:

self.playButton.setNeedsFocusUpdate()
self.playButton.updateFocusIfNeeded()

For more details about the tvOS focus engine I recommend reading this blog post explaining how to play around with it.

App Icon Parallax Effect

tvOS introduces a built-in parallax effect for developers. The app icon can be created using different image layers, and the system will automatically create the parallax effect for you, no extra work needed. To create your icon, you can either use the Xcode `xcassets` folder or use Apple’s Parallax Previewer software available on Apple’s developer portal. Both will ask you to provide one or multiple images and and then will generate a file for you that tvOS can consume to create the effect. For the most part, this effect is made up of three images: background, middle and foreground images, which combine to generate amazing parallax effects very easily.

tvos_icon

You said Javascript?

Unlike iOS, tvOS allows for developers to build apps using Javascript instead of one of Apple’s native options. This option will definitely help a lot of companies who don’t have enough resources for native development in Objective-C or Swift or would want to display content without reinventing the wheel and doing it all over again.

In order to achieve this, Apple released a new markup language to make it easy to use Javascript to create your app:

  • TVML: Television Markup Language, used to create an individual page using XML format.
  • TVJS: Javascript APIs to display data in your Apple TV app using TVMLKit.
  • TVMLKit: Lets you incorporate Javascript and TVML files into your app. It’s the link between TVML, Javascript and the final tvOS app.

Apple provides 18 templates that you can use to get started building TVML files. All you need to do is handle the logic in your Javascript files to display your data and respond to interactions.

While being able to use Javascript is great, there are some limitations. You will probably only want to develop your tvOS app using it when you don’t need to have a very custom design. With all of the templates available, you should have enough to pick a design suitable to the content you want to display. However, if you want a very specific UI, you will have to go native and use the tvOS frameworks.

Limitations

Building apps for Apple TV comes with some limitations. If you are a video game developer, you should of course consider the hardware specs for graphics (as always), but for most apps the new A8 CPU should be more than enough to handle your content. Outside of hardware concerns, here are some limitations for developers to consider when working on your app:

App size limit

An Apple TV app cannot be more than 200MB when downloaded from the App Store. If your data exceeds that limit, you will have to use the iOS 9 On-Demand APIs to asynchronously download and install specific parts of your app.

No persistent storage

There is no persistent storage for Apple TV apps; anything that is stored locally can be deleted at anytime by the system without warning you before. If your app needs to store data, you have to use iCloud Kit or your own personal database system.

No web views

Everything has to be native for Apple TV apps. tvOS does not allow the use of web views to display content, and Apple is really pushing developers to work on a native experience for Apple TV. Because a lot of apps in the market utilize web views, this could be a big challenge if your app is relying a lot on it. Luckily, the ability to develop tvOS apps using Javascript should mitigate a lot of the fallout from this limitation.

The remote

“Minority Report” is not real yet, so the only way to interact with apps is the Apple TV remote, and this will impact the way you design and program your app. Think about the user experience a lot before digging into the code and trying it on the simulator. You will be surprised to see how hard it is to use the simulated remote to navigate your app. These are the obstacles that will need to be overcome when you begin build an app for tvOS.

Final impressions

After working a little bit with the beta SDK, I am really happy to see that tvOS is pretty stable. I did not experience any crashes or major issues; however, my prototype app was also pretty basic so I may not have encountered them.

For a brand new product, the documentation is already very detailed and helpful, for both UX and development. This makes it easy to jump in and make a solid, production-level tvOS app without much trouble since everything that you need to do is outlined very clearly. Be sure to comb through Apple’s developer portal resources for tvOS before starting on your app.

Finally, I’d like to share the prototype I worked on for this post to test the tvOS SDK and get a feel for how it works. The app is pretty simple, pulling in videos from one of my favorite (French) YouTube channels, displaying them in a grid, and pushing a detail page with a play button to start streaming the video directly through your Apple TV. While the project is definitely rough around the edges, I feel that it highlights many of the elements that I discussed in this post, and it should act as a decent example for anyone jumping into tvOS development without any reference. Be sure to check it out on GitHub.