tvOS Development: An iOS Developer’s Perspective
By Martin Young, Senior Developer
Transitioning into tvOS development from iOS is a mostly painless process. However, there are a few key differences that should be noted before development begins.
The tvOS focus engine controls which UI element is currently selected, or “focused,” and automatically determines the next selection when the user swipes on the touch pad. For the most part, this process is automatic, requiring developers only to create interactable UI elements, such as UIButtons, which are then automatically selected by the focus engine.
It is important to note that you cannot directly bring an element into focus. Instead, you set your current focus environment’s “preferredFocusView” and then call “setNeedsFocusUpdate.”
App Size Limit.
Apple has decided that tvOS apps cannot exceed 200MB for their initial download. If your app requires more disk space, you will need to download additional resources at runtime. These are called “On-Demand Resources”, and Apple can host these for you on the cloud. However, this additional content is downloaded into a cache that can be removed by the operating system. If this occurs, you will have to re-download the content.
Event Forwarding and the Menu Button.
Now that there are more buttons for users to touch, understanding the event forwarding chain becomes even more important.
This is especially relevant for handling menu button presses. Apple requires that you allow users to exit your app by pressing the menu button from a logical place, such as your home screen. However, you may wish for your menu button to do other things depending on the context (e.g. opening a pause menu). This means you will need to intercept menu button press events before they are bubbled up to the UIApplication instance, otherwise the app will automatically close.
I strongly advise that iOS devs review how event forwarding works so that they can take advantage of the new interface.
Handling Remote Input.
tvOS provides a means to access low level input data from the new remote. You can use this to do more than just navigating menus. For example, you might want to allow the user to manipulate an onscreen cursor. To accomplish this, you can use the GameController framework or intercept input with drag gesture recognizers.
tvOS provides very limited control over the onscreen keyboard. In most cases, the keyboard takes over the entire screen. If you want to display the keyboard simultaneously with your content, you should use the UISearchController.
In short, there are no web views in tvOS. Plan accordingly.
At the time of this writing, there are very few analytics platforms that support tvOS. That said, this is changing rapidly.
tvOS and iOS cannot share storyboards. If you plan on targeting both platforms, you will need to create a storyboard for each.
UI Design Differences.
The remote interface opens up new design possibilities and challenges. For example, you have a back button on the remote so providing one on screen may not be necessary.
In summary, iOS developers should have no serious problems transitioning to tvOS, but they would be wise to get acquainted with some of the differences before diving into the deep end.