It's easy to run Telerik UI controls on tvOS. Here's how.

Mobile operating systems are multiplying rapidly those days. But only a few are able to capture people's hearts and pockets, while others sink in oblivion despite the fact that behind them are mighty companies. So, it is interesting to see how Apple manages to multiply its list of operating systems. Their current count is now four: Mac OS, iOS, WatchOS and the latest addition tvOS. tvOS is not exactly a mobile OS, it is designed for our living room and runs only on the latest  generation Apple TV. However, it looks more similar to iOS than WatchOS from a developer perspective. All core frameworks like UIKit, CoreGraphics and even SpriteKit are available.

Like true Apple fans and contributors to the Apple ecosystem, we were quite eager to see if Telerik UI for iOS will run on tvOS. Despite some small gaps (like TKCalendar depending on EventKit, which is not part of tvOS) it proved to be easy to run our controls on tvOS. 

Telerik UI for iOS on tvOS

A comparison list with the frameworks ​for tvOS is available here.

So, to test how Telerik UI for iOS runs on tvOS, we quickly stripped the EventKit dependance and… let’s now see how to create our first “hello world” application with UI for iOS on the tvOS. 

Starting with tvOS is easy, if you know how to develop with iOS on iPhone or iPad. Just follow the steps below:
  1. Open Xcode, choose “Create a new Xcode project” and select tvOS from the list. You can decide between Game, Single View Application and Tabbed Application. In our case, we will use Single View Application. Creating a new tvOS project
  2. Give your project a name and choose Swift as your language. Of course, you can use Objective-C, but we will use Swift for this post.
  3. Create your project.
  4. Go to the Project Settings page and add a reference to the UI for iOS library by using the Linked Frameworks and Libraries dialog. You should use the Add other button and locate the framework in Telerik UI installation folder. Linked Frameworks and Libraries
  5. Xcode 7.1 has an issue with finding frameworks, so you should do one more step: add the path to Telerik UI framework explicitly in the Framework Search Paths property. Framework Search Paths
  6. Since we are using Swift, we should add an empty Objective-C class to bring up the Create Bridging Header dialog. Click the “Create Bridging Header” button when prompted; after that you can safely remove the unnecessary Objective-C class and its files.
  7. Open the bridging header file, and add a reference to Telerik UI: Bridging Header
  8. Open the ViewController.swift file and replace the viewDidLoad method with the following one: 
    override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
             
         let calendar = TKCalendar(frame: CGRectMake(1000, 100, 800, 800))
         self.view.addSubview(calendar)
           
         let chart = TKChart(frame: CGRectMake(100, 100, 800, 800))
         chart.legend().hidden = false
             
         var items = [TKChartDataPoint]()
         items.append(TKChartDataPoint(name: "Apple", value: 17.9))
         items.append(TKChartDataPoint(name: "Samsung", value: 24.4))
         items.append(TKChartDataPoint(name: "Lenovo", value: 6.5))
         items.append(TKChartDataPoint(name: "Huawei", value: 5.1))
         items.append(TKChartDataPoint(name: "LG", value: 4.5))
         items.append(TKChartDataPoint(name: "Xiaomi", value: 4.5))
         items.append(TKChartDataPoint(name: "Others", value: 37.2))
             
         let series = TKChartPieSeries(items: items)
         series.selectionMode = TKChartSeriesSelectionMode.DataPoint
         series.selectionAngle = -M_PI_2
         series.expandRadius = 1.2
         series.style.pointLabelStyle.textHidden = false
         chart.addSeries(series)
             
         self.view.addSubview(chart)
             
         chart.select(TKChartSelectionInfo(series: series, dataPointIndex: 0))
    }
  9. Build and run the project, and you should see the following screen: Chart for iOS on tvOS by Telerik
Voila! This is how easily you can run UI for iOS on the tvOS.

Of course, you can’t interact with tvOS the same way you do in iOS. The only interaction device you have is the Apple TV remote. As we learn more about tvOS and its interaction features, we will optimize our controls accordingly.

As usual, the complete source code of this project is available at our public ​GitHub repository.

That project would need a UI for iOS build with the EventKit dependance removed. We are considering shipping such a build in a future version. Let us know in the comment of the blog or the UI for iOS Feedback Portal if you need such a build to run on the tvOS.

With Q3 2015 release, we will ship AutoCompleteBox and Gauges components, as well as the official version of the DataForm component. Following the official release of Xcode 7 and iOS 9 along with Swift 2.0, our controls will be fully optimized for Swift 2.0.

Download UI for iOS by Telerik
Tsvetan Raikov image
About the Author

Tsvetan Raikov

Tsvetan is the Team Leader of the UI for iOS team. He has been part of Telerik since 2006, when he joined the company as regular developer in the WinForms team. Tsvetan made his way through all developer postions over the past few years. His addiction to the cutting edge technologies, together with the passion to develop outstanding products are what drive him forward. In his spare time Tsvetan loves biking, hiking and snowboarding. You can find Tsvetan on Twitter @tzraikov, and LinkedIn.

Comments

Comments are disabled in preview mode.