tvOS SDK: An iOS Developer’s Initial Impressions
Check out what an iOS developer thinks of Apple’s newly released tvOS SDK – including details on development tools, TVML, the touch engine, and more! By Chris Wagner.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
tvOS SDK: An iOS Developer’s Initial Impressions
20 mins
Custom Apps
When you need to get down to the nuts and bolts and provide a one-of-a-kind experience you will need to brush off your iOS skills and work your UIKit-fu.
Many of the iOS frameworks you know and love like UIKit, Core Graphics, SpriteKit, CloudKit, and more are available on tvOS – you can see the whole list of what is (and isn’t) included here. If you are an existing iOS developer, you should feel very empowered by this list!
Writing a tvOS app can be done using both Swift, Objective-C and C (I have not seen anything to say C++ is off limits either).
Although there’s definitely a lot of new material to learn about making custom apps for tvOS, you should feel right at home as an iOS developer.
Focus Engine
One concept that will be new to iOS developers is the user input method. Users will not be touching your UI with their fingers or noses (you know you’ve done it or at least thought about it!). But rather, they will be using the provided remote control or even a game controller.
tvOS introduces a system known as the focus engine. The main concept is that there is always one — and only one — item that is in focus at a given time. Users navigate your UI by using swipe gestures or a directional pad/control to move up, down, left or right.
The focus engine automatically decides which view to focus based on user input; you don’t have to do anything. For example, you just arrange your views in your Storyboard, and if one of the views is focused and the user swipes right, the focus engine will automatically find the closest view to the left of the selected view and focus it for you.
As a developer, there are some new APIs related to the focus engine you’ll want to be aware of. There are APIs for your app to get notified when the focused item updates, to programmatically trigger a focus update, and much more. For more info, check out the Supporting Focus Within Your App section of the App Programming Guide for tvOS.
TVServices
Although tvOS development relies primarily on iOS frameworks you may already be familiar with, there are a few new frameworks to be aware of, such as the new TVServices
framework.
The TVServices
framework is primarily used to describe content in your app so that the system can display it on the “Top Shelf”. When a user places your app in the top row of their home screen your app is considered one of the most important apps that the user has installed.
This is an excellent opportunity to provide extra value to your users by giving them shortcuts to content they may be interested in. For a game, it may be game saves so they can jump right back into the action. For a social media app, you may have trending content that appears on the top shelf. And a photo sharing app may show off recently shared pictures by friends and family.
Check out the TVServices Framework Reference for more information on how to implement this feature. It is very important that you take full advantage of this opportunity.
Parallax Images
One thing that may have struck you as a little odd in the Keynote was the presenter’s emphasis on parallax effects happening on images and app icons. This is a really neat visual effect, but what’s so important about it?
As you play around with the tvOS simulator you’ll begin to understand why it’s so important: to move the focus item, you need to swipe a fair bit to the left or right. But if you swipe a little bit (but not far enough) Apple will begin to rotate the focus item, in order to give you a visual cue that you are doing something (but need to continue swiping to change the focus). It’s subtle but powerful.
Apple considers the parallax effect a key component of tvOS design. It is required of your App’s icon and highly encouraged for other media such as movie poster art.
Thankfully, Apple has outlined exactly how to create these assets in the Creating Parallax Artwork section of the App Programming Guide for tvOS, and has even provided a neat previewer app.
Controllers
Everyone who buys the new Apple TV will receive a powerful new remote control. The previous generation was very simple with a directional pad and couple other navigational buttons. The new Apple TV remote has some exciting new features, specifically:
- A glass touch surface at the top which allows the user to perform gestures like swipes, taps and clicks.
- A microphone which provides access to Siri (Siri is restricted to a certain subset of countries) and the ability to control volume on your TV or audio system.
- A gyroscope and motion sensor to provide a great gaming experience. The user can tilt the remote side to side perhaps to steer a car down a street or hero running through caverns.
You can use gesture recognizers you know and love to detect swipes and taps, and there are also new pressesBegan()
, pressesEnded()
, pressesChanged()
, and pressesCancelled()
APIs to detect when various buttons on the control are selected.
The remote communicates using Bluetooth, which leaves the door wide open for Bluetooth game controllers (especially since the default remote isn’t particularly well suited to games IMHO). Apple has already announced that the Nimbus Steelseries Controller will be available for the new Apple TV. Check out the Working with Game Controllers section to learn more.
tvOS and Games
We’re willing to bet that games will be really hot on tvOS – Apple seems to be aiming squarely at Nintendo’s casual games market.
tvOS has strong game support. SpriteKit and SceneKit both work on tvOS, and in the keynote the Crossy Roads developer showed a tvOS port of their game, which is made in Unity, which implies Unity support may be coming in the future as well.
Many SceneKit games port almost seamlessly to the Apple TV. For example, Ray ported Zombie Conga from iOS Games by Tutorials to the Apple TV in less than 10 minutes, without even having to change any code:
This ease of porting games is sure to boost Apple TV’s initial games catalog!