Launching an Apple TV App: What we’ve Learned so Far
CEO & Founder of Server Density.
Published on the 7th January, 2016.
Think the Apple TV belongs in the living room? Think again.
Since 2007, when it launched alongside the first iPhone, this diminutive box has been creeping into meeting rooms and presentation facilities alike. A typical case of BYOD, it seems, folks carried their personal Apple TVs to the office and started streaming their content on large HDTV displays.
Last September, Apple announced the latest iteration of Apple TV, expanding its appeal to a broader set of business scenarios, including the enterprise.
The main new feature—and the one that grabbed our attention—is the ability to develop native 3rd party apps using the new tvOS SDK. Apple TV is no longer just a digital media player. With what Apple calls “desktop class” specs, new interaction modalities and a dedicated App Store, it’s fair to say there is plenty of new stuff for developers to explore.
To get a better understanding of this new platform, we decided to invest a few weeks and develop a Server Density Apple TV app. Here is what we’ve learned.
Building an Apple TV App
tvOS is based on iOS. Even though we’ve been developing on iOS for years, making an app for tvOS involved quite a bit of a learning curve. That’s mainly due to the new interaction method (remote control swipes).
Having an app on the App Store in time for Apple TV launch turned out to be quite a challenge. To begin with, we only qualified for the second round of dev kits which gave us a month of a late start. Then we had to learn the new API. Apple TV was only announced in September which means there was hardly any knowledge pool or examples we could tap into.
It took us 45 days to develop the app, including 2 weeks of visual design. Much of that was spent looking for information and getting to know the platform. Future projects should take significantly less time to complete.
App Thinning and “on demand resources”
App Thinning (and Bitcode Recompiling) was introduced in last year’s June developer conference (WWDC) as part of iOS 9. It allows tvOS apps to only download device-specific assets, and therefore conserve storage space.
While App Thinning is optional for iOS, Apple decided to make it compulsory on tvOS. That’s probably because it’s a brand new platform, without legacy attachments preventing developers from implementing it from the get go. Another reason might be related to usage patterns. Apple TV is supposed to carry media-heavy apps, like films and games that carry heavy binaries.
tvOS also requires the adoption of “on demand resources”, which means initial downloads cannot be more than 200MB. The rest of the app streams down at a later stage, as needed. Seeing that the Apple TV is a constantly connected device, we think this requirement makes sense.
Since WWDC, developers were given a few months to get up to speed with App Thinning, in time for iOS 9 launch in September. Focus Engine was an entirely different story.
You could in theory port your existing app to iOS and it will probably function. But for users to be able to interact with it as a native app (with the new remote control), you need to leverage the Focus Engine.
Focus engine is a set of interaction rules for manipulating the focus on the various options displayed on the Apple TV display. It was announced last September—as part of Apple TV—giving developers a few weeks before the actual launch in late October.
Again, there were no solid examples or books on this topic, save for the official Apple documentation which was rather pithy (euphemism) and felt like work in progress (situation has improved since).
Overall we had to experiment quite a bit. For example, the rules for moving focus around the screen were not that clear. To place the currently selected dashboard in focus (instead of the first one in the list), we found we had to “trick” the Focus Engine.
If you’re just starting your development efforts on those new technologies, we’ve collated a short list of tips that should save you some time.
tvOS Development Tips
1. Connect the Apple TV remote to your Mac
While waiting for the Developer Kit to arrive, we had to work with the simulator. The simulator caters for a faster edit-build-run cycle but we found it was somewhat cumbersome.
There’s an on-screen remote overlay, which you invoke with ⇧-⌘-R, but we found it finicky to use. It is quite small and you need to press the Option key while you simulate remote finger swipes.
There is, however, a little known trick that can make your development life much easier. You can pair the actual remote with your Mac (El Capitan). The simulator will recognize it and allow you to interact with it.
To do that, you need to unpair it from the AppleTV device first. Bear in mind that the remote has a strong affinity to the AppleTV. As soon as you unpair them they will almost immediately pair again. The most effective option (short of turning Bluetooth off) is to power the Apple TV down, until the new pairing is complete.
On the remote, press the MENU and Volume Up buttons together for a few seconds. On the Mac, launch the System Preferences app and navigate to the Bluetooth panel. The Apple TV should show on the list of discovered devices, where you can complete the pairing process. You will notice the focus of the simulator obeys your Remote gestures. Go ahead and knock yourself out with focus wiggles now.
2. Connect your Mac to the AppleTV
Apple product packaging usually errs on the small size. We like the principle, but we kind of wished the Dev Kit had some extra space for a much needed cable: the one that connect the Apple TV to your development Mac.
From what we’ve heard, the first round of dev kits did include this cable. Alas, the subsequent dev rounds, and commercial edition of Apple TV, do not. The only included cable is a USB to Lightning cable meant for charging the remote.
You can, of course, install apps via TestFlight. On the first beta of tvOS, however, there was no App Store app, so we couldn’t even install TestFlight. In any case, when debugging and receiving logs, you do need a cable connection to the device.
It would be nice if Apple allowed wireless development, or perhaps an Ethernet connection via a Thunderbolt-Ethernet adapter. As it stands you can only use a USB-C cable. Oh, and Apple doesn’t stock the cable. What they do offer is the “USB-A female to USB-C” variant, but that’s not what we need.
We had good results with the one from Orzly, but YMMV. As long as you don’t try to force the Lightning cable in the USB-C port, you’re good.
The use-cases of this cable extend beyond development. For example, you can use it to install system updates. If you’re managing several Apple TV boxes, then this functionality will prove useful (to replace over-the-air updates). You can also use this cable to capture video from the Apple TV (see next tip).
3. Save video from an AppleTV
Let’s say it’s time to promote an AppleTV app—or to report a bug in one—and you want to capture some footage from an actual, running device. Capturing straight from the simulator is a no-no, as you’ll get various OS X decorations (unless you finetune the screen region that you are capturing).
One way to do it would be with an HDMI capture device, but those gadgets are expensive and they lead to video compression artifacts. The better option is to connect your Apple TV to a Mac with the aforementioned USB-C cable.
Launch Quicktime and start a video capture session. Select the Apple TV device as the source and press REC.
4. Use iOS CocoaPods with AppleTV
During the development of our tvOS app, we found ourselves wanting to use third party open source libraries. The standard way to incorporate these libraries is using Cocoa Pods (yes, Carthage also, but most projects support Cocoa Pods first).
The problem was that the podspec files (the recipe to incorporate these libraries) of these libraries had—in most cases—not been updated for tvOS. This is not surprising, as most maintainers hadn’t experimented with tvOS yet.
Adding support for tvOS to an iOS library is, in most cases, straightforward, since the code is 100% compatible, save for very small differences related to input handling (and most libraries do not concern themselves with that). So it is truly just a matter of rebuilding the library for the new target.
We could have just incorporated the code as is but that would make things messy in the long term. So we looked into modifying the podspec files to add support for tvOS. Doing so meant we could start using those pods straight away instead of waiting for the respective project maintainers to do so.
All we had to do was add a single line to the
.podspec file of each library:
s.tvos.deployment_target = "9.0"
Then we just needed to tell the Pods tool to look into our local working copies instead of fetching the libraries from github. This was also simple. In the
Podfile of each pod we can provide a URL that overrides the default location. File paths happen to be valid URLs:
pod 'SwiftyJSON', :git => '../SwiftyJSON'
After verifying that the code works as expected on tvOS, we contributed these changes back. We did this, so that we can switch back to the default repositories as soon as possible (we didn’t want to miss out on any future improvements). As soon as they accepted our contributions, we edited the
Podfile lines to point back to their default repositories.
From Bitcode Recompiling to the new Focus Engine, last year’s Apple TV refresh came with plenty of new technologies for developers to sink their teeth into. We hope the tips in this article help smooth out your development journey.
Got some Apple TV successes, horror stories and tricks? Let us know in the comments.