How to develop Apple tvOS applications?
Until a few months ago, Apple tvOS was a marvel for both the programmers and users, the tvOS App Store shelves were empty because of the lack of goods. Now the situation has changed radically. The developers are actively working on the creation of applications that can run on the digital media players of the fourth generation. If you want to join their ranks you should consider the fact that there are two ways to develop the apps suitable for tvOS. Also, bear in mind that Apple has released new tvOS version recently. Go ahead and check it's new features. Afterwards, you can take a decision which development approach will serve you.
What's new in Apple tvOS 9.2?
Even though the new 9.2 version is a beta one, you can have a quite clear imagination of what the future innovations are going to be about.
First of all, it has become possible to arrange the applications into folders. The look of folders is very similar to the iOS ones. So, get ready to sort out the mess on your Home screen:).
Siri has learnt some new languages. In addition to the previous languages, now you can talk to it on U.S. Spanish (for the USA citizens), French Canadian (for the Canadian citizens), UK English, US English, Australian English (for the United Kingdom citizens).
Significant changes have been made to the App Switcher. Now it has an iOS-like look.
MapKit got supported by tvOS. So, you can watch maps in your tvOS applications.
With the latest version, Podcast is now available on Apple tvOS.
The typing is much simplified with the new Bluetooth keyboards. Now you may not rely only on Siri Remote which is far from the ideal but fully control your typings.
Among the new features supposed to appear in future, we can mention accessing iCloud Photo Library and Live Photos used to create the gif-stills.
As you can see, Apple never ceases to amaze with innovations. It introduces more and more possibilities both for the developers and users. If you're thinking of replenishing the Apple tvOS app store, the information below will be useful.
How to develop?
The first thing to consider is the development approach you are going to use. The Apple tvOS app can be written either in a native programming language or with the help of specific technologies unique for this operating system.
In case you are a native iOS developer, you are free to use familiar technologies and code on Objective-C or Swift.
If you have no idea of how to operate the languages mentioned above or simply want to try new programming techniques, pay attention to the Television Markup Language. It was created with the purpose to develop the apps suitable for the devices which support Apple tvOS. You will not be able to push such app to the device of a different type.
Let's take a closer look at each kind of the application and try to find out which one will be suitable for you.
Native Apple tvOS App
The concept of the native app is well understood by the developers. It implies using native OS programming languages and bridging tools.
iOS apps are mainly coded in Objective-C or Swift. Also, you can insert some portion of pure C or C++ if needed. Use the Interactive Development Environment (IDE) to produce the native code. For iOS development, you are going to employ the xCode IDE. This tool will help you to edit and analyse the code, find bugs and memory leaks, actually build the application, etc.
To adapt or develop particular features of the application you can use numerous frameworks and APIs provided by Apple. The frameworks make the developers' life easier by helping to implement various functions such as creating user interface, uploading data (e.g., photo, video), encrypting some information, determining geolocation, playing video and audio content, etc. In such a manner, developers don't have to reinvent the wheel, they simply use the predefined mechanisms and methods.
How about developing for tvOS? Are there any peculiarities for the native apps? Actually, the logic of the development is the same: write native code and implement certain features with the help of APIs and frameworks. Of course, you will have to use specific frameworks which you may not be familiar with. However, Apple tvOS SDK included into xCode 7.1. offers a plenty of the frameworks which you definitely have been working with if you do native iOS development. Do the UIKit, Metal, CloudKit, CoreData, CoreGraphics sound familiar to you? They are available on tvOS as well.
Anyhow, be ready to discover innovations provided by Apple in order to make a tvOS suitable app.
The first thing to be considered is an unaccustomed way of navigation. Unlike iOS devices, Apple tvOS devices are not designed so that users could interact with them directly. That is, they do not tap or swipe the screen but use a remote way of interacting and navigating. For this purpose, Apple has made a reasonable change in the UITabBarController which is a part of the UIKit framework, particularly:
- the tab bar would appear at the top of the window and would disappear in case the focus is moved away;
- the focus will be directed to the content view in case the user swiped down;
- in case the tab bar is focused and user presses 'Select' the content view gets focused instead;
- there is no way to customize the tab bar due to the fact that it displays the view controllers from the viewContollers array.
Another thing to bear in mind is a focus. It is used to pick up the objects which users can see on the screen by means of remote control. With this purpose, Apple has created the UIFocusGuide which is a part of the UIKit framework. UIFocusGuide helps to identify invisible objects and make them focusable. The focus movements are also controlled with the help of this programming interface.
Also, Apple has added totally new frameworks which you haven't met earlier. One of them is TVServices. You can employ it to provide users with the ability to preview the apps content. The most important apps can be afterwards placed in front of others on the so-called 'top shelf'.
TVML App for Apple tvOS
Here are three abbreviations that you have to remember in order to successfully make Apple tvOS application: TVML, TVJS, TVMLKit. It's OK if they sound alien. Let's try to figure out what is what.
TVML (a full name - Television Markup Language) is a kind of XML. You can use it to create the separate pages of your future app;
The TVML apps are often called the Client-Server apps because they are mainly developed with the purpose to stream the video content and do not suppose that users will frequently interact with the app's interface. Such apps are built so that the eventListener catches the commands sent by the user via the Interface (e.g., when pushing the Play button). The events themselves are processed on the server which returns responses to the users' requests.
What is better?
Let's look at some parameters by which we can judge the pros and cons of different types of the applications.
If you want to make an app that involves frequent use of the interface rather than just watching a screen by pressing a single button the native app would be a better choice. However, if your app is intended, for example, to stream a video content, TVML is just what you need.
Learning new technologies
If you are a native iOS developer, you may not want to spend time for learning new TVML techniques but use the existed knowledge and code on Objective-C or Swift instead. However, if you do not belong to the number of iOS developers, the TVML may be a better choice for you.
Time of development
It is not going to vary too much in case you are familiar both with Objective-C/Swift and TVML techniques. The time will depend on the specifics of the app. The way of development does not influence it directly. However, if you want to create a streaming video app, the TVML format will save your time as it was developed specially for the apps of this kind.
A well-known fact is that the higher level applications are less capable of customization. In simple words, you can use specific templates and do not write some part of the application manually, but you can not customize it. In view of this, the native app may be better in case you want to create a unique-designed multifunctional application.
Things to be considered
No matter which way you are going to develop your app there are important things that you should take into account.
Remote control events
Since the users do not have the ability to tap or swipe the screen the way it is possible with other devices (phones, tablets, etc.), triggering remote control events is an essential part of the tvOS application.
It should be noted that the tvOS is developed on the basis of iOS. That is why they have much in common. While in a version earlier than 7.01 the remote events were triggered with the help of beginReceivingRemoteControlEvents, starting from iOS 7.01 it is done via the shared MPRemoteCommandCenter object. It supports a variety of events by providing command objects for each of them. You can choose which events should be triggered by your app and disable the unnecessary ones. For that, you can set enabled property of the corresponded MPRemoteCommand object to No. Check this link to find out more about handling remote control events on the tvOS.
App size restrictions
The Apple tvOS apps have size restrictions. Particularly, your application should not 'weigh' more than 200 Mb. Otherwise, you will have to load some portions of it separately by means of Apple On-Demand Resources.
Apps developed for new OS do not have an external repository. It means that the data kept in a local way can be deleted at any moment. To avoid this, you should use either your own database system or iCloud Kit.
No web views
There are no outstanding pros and cons both of native iOS and TVML applications. The main difference is that a certain approach to programming may be more or less suitable according to the specifics of your application. You should choose a native app if it requires an active interaction with the user interface. TVML app is more appropriate if users are going to employ the interface marginally, for example, watching movies and tv shows broadcasting through your application. Regardless of the fact which app you've chosen to develop, you should take into account the restrictions provided by Apple, namely, app size, external storage, web views limitations and the peculiarities as for triggering remote control events.
If you need any help in building tvOS app of your dream, please get in touch with us!