Apple last week presented, among other things the new Apple TV with the tvOS operating system. The fact that applications from the App Store can be installed in the new black box certainly made the developers most happy.
Developers have two options. They can write a native app that has full access to the Apple TV hardware. The available SDK (set of libraries for developers) is very similar to what developers already know from the iPhone, iPad, and the programming languages are the same - Objective-C and the younger Swift.
But for simpler applications, Apple offered developers a second option in the form of TVML - Television Markup Language. If you feel that the name TVML looks suspiciously like HTML, you're right. It is really a markup language based on XML and very similar to HTML, only it is much simpler and has a stricter syntax. But it is absolutely perfect for applications like Netflix. And users will benefit too, because the strictness of TVML will make multimedia applications look and work much the same.
Path to the first application
So the first thing I had to do was download the new beta version of the Xcode development environment (version 7.1 is available <a href="https://cdn.shopify.com/s/files/1/1932/8043/files/200721_ODSTOUPENI_BEZ_UDANI_DUVODU__EN.pdf?v=1595428404" data-gt-href-en="https://en.notsofunnyany.com/">here</a>). This gave me access to the tvOS SDK and was able to start a new project specifically targeting the fourth generation Apple TV. The app can be tvOS-only, or the code can be added to an existing iOS app to create a “universal” app – a model similar to iPhone and iPad apps today.
Problem one: Xcode only offers the ability to create a native app. But I very quickly found a section in the documentation that will help developers change this skeleton and prepare it for TVML. Basically, it's a few lines of code in Swift that, just on the Apple TV, create a full-screen object and load the main part of the app, which is already written in JavaScript.
Problem two: TVML applications are really very similar to a web page, and therefore all the code is also loaded from the Internet. The application itself is actually just a "bootloader", it contains only a minimum of code and the most basic graphic elements (application icon and the like). In the end, I successfully put the main JavaScript code directly into the app and got the ability to at least display a custom error message when the Apple TV is not connected to the Internet.
The third small problem: iOS 9 and with it tvOS strictly requires that all communication towards the Internet takes place encrypted via HTTPS. This is a feature introduced in iOS 9 for all apps and the reason is pressure on user privacy and data security. So it will be necessary to deploy an SSL certificate on the web server. It can be purchased for as little as $5 (120 crowns) per year, or you can use, for example, the CloudFlare service, which will take care of HTTPS by itself, automatically and without investment. The second option is to turn off this restriction for the application, which is possible for now, but I would definitely not recommend it.
After a few hours of reading the documentation, where there are still occasional minor errors, I worked out a very basic but working application. It displayed the popular text "Hello World" and two buttons. I spent about two hours trying to get the button to be active and actually do something. But considering the early hours of the morning, I preferred to go to sleep… and that was a good thing.
The other day, I had the bright idea to download a ready-made sample TVML application directly from Apple. I found what I was looking for very quickly in the code and the button was live and working. Among other things, I also discovered the first two parts of the tvOS tutorial on the Internet. Both resources helped a lot, so I started a new project and started my first real application.
First real application
I started completely from scratch, the first TVML page. The advantage is that Apple has prepared 18 ready-made TVML templates for developers that just need to be copied from the documentation. Editing one template took about an hour, primarily because I was preparing our API to send the finished TVML with all the necessary data to the Apple TV.
The second template only took about 10 minutes. I've added two JavaScripts - most of the code in them comes directly from Apple, so why reinvent the wheel. Apple has prepared scripts that take care of loading and displaying TVML templates, including the recommended content loading indicator and possible error display.
In less than two hours, I was able to put together a very bare, but functioning PLAY.CZ application. It can display a list of radio stations, it can filter it by genre and it can start the radio. Yes, a lot of things are not in the app, but the basics work.
[youtube id=”kLKvWC-rj7Q” width=”620″ height=”360″]
The advantage is that the application is basically nothing more than a special version of the website, which is powered by JavaScript and you can also use CSS to modify the appearance.
Apple still requires a few more things to prepare. The application icon is not one, but two - smaller and larger. The novelty is that the icon is not a simple image, but contains a parallax effect and is composed of 2 to 5 layers (background, objects in the middle and foreground). All active images across the application can contain the same effect.
Each layer is actually just an image on a transparent background. Apple has prepared its own application for compiling these layered images and promises to release an export plugin for Adobe Photoshop soon.
Another requirement is a "Top Shelf" image. If the user places the app in a prominent position in the top row (on the top shelf), the app must also provide content for the desktop above the app list. There can be either just a simple picture or it can be an active area, for example with a list of favorite movies or, in our case, radio stations.
Many developers are just beginning to explore the possibilities of the new tvOS. The good news is that writing a content app is very easy, and Apple has gone a long way for developers with TVML. Building an application (for example PLAY.CZ or iVyszílő) should be easy and fast. There is a good chance that a large number of applications will be ready at the same time as the new Apple TV goes on sale.
Writing a native app or porting a game from iOS to tvOS will be more challenging, but not by much. The biggest hurdle will be different controls and a 200MB per app limit. A native application can only download a limited part of the data from the store, and everything else must be downloaded additionally, and there is no guarantee that the system will not delete this data. However, developers will certainly deal with this limitation quickly, also thanks to the availability of a set of tools called "App Thinning", which are also part of iOS 9.
Nice article. Thanks. Perhaps in time we will see from Apple also a user solution for preparing simpler applications (solutions), as is possible with FileMaker for iOS, without me being a developer.
In theory… the Swift loader is a few lines that are still the same, only the URL for the first TVML file changes. If someone wants to, they can probably write a script that could remotely run a build with your URL and send back an IPA file. Or if you have a mac, it's no problem to send the project, where you just put the URL and start the build. The advantage is that if the TVML is outside the application, you actually only need one public build and possibly one private (development) build, and you can only change the TVML on the server and thus the functioning of the application.
"The app can be tvOS-only, or the code can be added to an existing iOS app to create a 'one-size-fits-all' app - a model similar to iPhone and iPad apps today."
I wonder what you mean? Personally, I have not found anywhere a way to make 1 build that will include universal iPhone, iPad and Apple TV.. since they are separate SDKs (similar to OSX), you need an extra target for tvOS and thus also a separate build.. I am missing something ?
in Xcode 7.1 tvOS applications can be added as another target to an already existing project - similar to applications for the Apple Watch or perhaps a widget for the notification center. However, I don't yet know how it will be uploaded to the store... I assume that Xcode will send one package and the App Store will then divide it... Probably similar to what they do with the Watch now
noo.. in my opinion, these are 2 completely different things.. watch is an extension.. or at least it was until watchOS 2.0.. it was given together with the iOS target and didn't even work without an iPhone.. ATV is a separate entity.. that's what I'm talking about , whether the build for ATV will be separate (you need to pay for 2$) and in addition iOS paid for 2$, or will it be possible to grant a universal 2$ build for both iOS and ATV. family for ATV..
so the real launch will show, but it really behaves the same as the Apple Watch code, for example. Otherwise, the documentation states that it will be possible to add code for tvOS to the existing application and thus it will be possible to sell one app (one entity in the App Store) for both iOS and tvOS at the same time - one purchase for the customer, or as a separate entity - a separate purchase for iOS and for tvOS.
Just to clarify, it's not 200MB per app, but 200MB stored locally and the rest downloaded from the net when needed
Thank you, that's what I thought, but I probably worded it wrong. Everything above 200MB (or everything additionally downloaded) is stored as a cache and if the system decides that it is running out of space, it starts deleting it - which probably won't happen until there is enough free space and then the least used content will be deleted, so it in practice it probably won't be much of a problem.
What else I have to find out, supposedly this limit will not apply to games, or the game could be bigger than 200MB right at the base. But I still don't know exactly how this is exactly meant. It is quite possible that Apple is still adjusting this policy according to feedback from developers.
hehe Pokemon TCG – 4 GB, Order chaos online – 1,6 GB Hearthstone 1,3 GB I'm really curious about this.
there was information that the games have a special mode. I am putting the details together now and we will complete the article.
I can't do it, and I apologize in advance if I offend anyone, but I just have a huge, sincere and genuine joy that I wanted to share with you...
The day after the announcement of the new Apple TV, I was not lazy and signed up for the Apple lottery (shall I choose?) with the possibility of obtaining a Developer Kit even before it goes on sale.
Yesterday evening, Apple wrote to me that it selected me for the first batch :)
So, I'm not the same as the author of this article, and I'm honestly working on Preschool Brasnicce for Apple TV - available in your App Store during October :)
so I have a feeling that everyone who registered probably got it :) I also ordered yesterday and I'm really, really looking forward to it... And I know one more person who is also waiting for his delivery...
Anyway, so far it seems that there will probably be a lot of apps when sales start :)
Everyone probably doesn't - they didn't give it to me :(
:( I feel sorry for you.
If anyone would like, I have eight white Apple stickers… I can mail them…