How to extend your iOS app to tvOS

I have an iOS app that needs to be expanded to tvOS. All the information I found explains how to start from scratch! Is there a way to expand my application on tvOS, or should I start a new project with it?

Update1: My question is: how to extend my existing project to support tvOS without creating it from scratch?

Update2: Jess Bauer points to the Apple website:

Empower users to use their favorite apps on both iOS and the new Apple TV with a single purchase, providing a one-stop purchase for your app on the App Store.

This means that we need to create a new package in our existing project and enable a β€œone-stop” purchase, so it will be considered one application in the App Store.

+47
ios tvos apple-tv
Sep 09 '15 at 10:16
source share
9 answers

The tvOS SDK is based on iOS, but is not interchangeable. Unlike when the first iPad was released, the new Apple TV will not be able to launch iOS apps.

In the AppStore for TV, only applications created specifically for tvOS will be included.

For any iOS developers who want to create apps for Apple TV, I would recommend checking out the new documentation page: https://developer.apple.com/library/content/documentation/General/Conceptual/AppleTV_PG/index.html#//apple_ref / doc / uid / TP40015241-CH12-SW1

In particular, check out the Inherited iOS Framework section to give you an idea of ​​what will work out of the box from existing iOS projects.

+25
Sep 09 '15 at 23:28
source share

In Xcode 7.1 (which introduces the tvOS SDK) you can add a tvOS target like any other (File -> New -> Target ... -> tvOS -> ...) and supports both Objective-C and Swift, so yes - sharing is possible codes between your iOS and tvOS application, you just need to check your target membership and include it in your tvOS target. To expand purchases in iOS and tvOS applications, we must use Universal Purchases.

+20
Sep 10 '15 at 12:10
source share

I also believe that adding a new target for tvOS is the way to go, especially if you have a lot of objective-c or quick code to share between projects.

In cases where some unsupported tvOS types may be present in your shared code, I used these preprocessor characters to provide alternative code snippets for tvOS:

#if TARGET_OS_IOS // iOS-specific code #elif TARGET_OS_TV // tvOS-specific code #endif 
+13
Oct 11 '15 at 13:17
source share

Took me a little to find everything that needed to be changed, but this list should cover it.

  • click iOS target and duplicate
  • change sdk base of new tvOS target to tvOS last
  • make a copy of info.plist and point tvOS to this
  • make all tvOS icons and run images
  • set TARGETED_DEVICE_FAMILY to 3 for tvOS build settings.
  • add any new versions of code specific to tvOS, for example. without shouldAutorotate, prefersStatusBarHidden, etc.
+12
Nov 02 '15 at 4:49
source share

Just list some of the limitations and problems:
1. On Apple TV there is no permanent storage for applications. Data must be stored in iCloud.

2. The maximum size of the Apple TV application is limited to 200 MB. You must use resources on demand (application content hosted on the App Store). The benefits are a smaller application size and lazy loading of application resources.

3. The user interface is very different. Human interface guides should be followed as for the document.

4. Creating a Client-Server application using JavaScript and TVML infrastructure.

5. Manage touch focus user interface. UIFocusEnvironment controls focus behavior for the view hierarchy branch. UIViewController conforms to the UIFocusEnvironment protocol.

6. Creating a Parallax Work You need to create an LSR image using Xcode and then use the terminal to create an LCR image. A UIImage object can correctly display an LCR image.

+9
Sep 10 '15 at 15:00
source share

The answer of Simon-Tillson is correct, however I had some problems with backward compatibility with iOS 8.1 and lower SDK, where TARGET_OS_IOS was not defined (for older versions of Xcode)

The following code fixes this and works the same for iOS 9.0 / 9.1 SDK + and previous 8.1 and less SDKS.

 #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) // iOS-specific code #elif TARGET_OS_TV // tvOS-specific code #endif 
+5
Oct 28 '15 at 8:04
source share

In the case of my project, I simply added a new target to an existing iOS project and modified some code accordingly (using #if os (tvOS / iOS) in several areas). Now I can run the same application on iOS or Apple TV devices.

The only infrastructure missing in tvOS was WebKit (which was needed to create rich text), and I needed to create an alternative mechanism.

I will soon open the source of this project (until the end of October) so that other people can watch.

+2
Oct 21 '15 at 7:56
source share
  • For tvOS, a new target must be added. There are two ways to do this:

    • Add a new target via File> New> File ...> tvOS Target.
    • Duplicate your existing iOS target and change TARGETED_DEVICE_FAMILY to 3 and Supported Platforms to tvOS in Build Settings
  • Routines must be added to the tvOS target using pod install . There may be another list of containers that you can / want to use in tvOS. Pods for different purposes can be divided into Podfile using:

     target 'iOS TARGET NAME' do pod 'podname', :git => 'https://github.com/name.git' end target 'tvOS TARGET NAME' do pod 'podname', :git => 'https://github.com/name.git' end 
  • Most Pods do not currently support tvOS. For these Pods, here are the steps to get them working in your project:

    • Hide git repository on local drive
    • If the pod version is used for another purpose (iOS target), change the name, otherwise CocoaPods will complain: for example. RestKit -> RestKitTV and use: path In the podcast to indicate the location of the cloned repo:

       pod 'RestKitTV', :path => 'Other/RestKitTV' 
    • Update podspec file in cloned repo:

      • Change the name to be compatible with the new name
      • Change platform to tvOS or add tvOS to the list of supported platforms

          Pod::Spec.new do |s| .. s.platform = :tvos .. end 

        OR

          Pod::Spec.new do |s| .. s.tvos.deployment_target = '9.0' s.tvos.exclude_files = 'framework/Source/Mac', .... s.tvos.frameworks = ['OpenGLES', 'CoreMedia', 'QuartzCore'] .. end 
  • Add files to target:

    • Add source code (.m files) to Compile Sources for Generate Phases for Target
    • Add Images to Copy Bundle Resources
    • Add the frameworks to the Link Binary Files to Libraries link. Please note that not all frameworks are compatible with tvOS.
  • Use TARGET_OS_TV and TARGET_OS_IOS macros to separate incompatible tvOS code

     #if !TARGET_OS_TV *iOS only code* #else *tvOS only code* #end 
+2
Feb 03 '16 at 21:23
source share

Remember to change the base SDK to TVos 9.x in the build settings. It is necessary that the TV simulator is displayed

0
Jun 01 '16 at 2:08 on
source share



All Articles