How to extend iOS app to tvOS

后端 未结 9 1769
别跟我提以往
别跟我提以往 2020-12-12 14:55

I have an iOS app that I need to extend to tvOS. All the information that I found are explaining how to start from scratch! Is there any way to extend my app to tvOS or I sh

相关标签:
9条回答
  • 2020-12-12 15:16

    +Simon-Tillson answer is correct, however I had some backwards compatibility issues with iOS 8.1 and below SDK's where TARGET_OS_IOS was not defined (for older Xcode versions)

    The following code fixes that 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
    
    0 讨论(0)
  • 2020-12-12 15:18

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

    For those instances where there might be some tvOS-unsupported types in your shared code, I have used these preprocessor symbols to provide alternate code snippets for tvOS:

    #if TARGET_OS_IOS
    // iOS-specific code
    #elif TARGET_OS_TV
    // tvOS-specific code
    #endif
    
    0 讨论(0)
  • 2020-12-12 15:21

    Don't forget to change the Base SDK into TVos 9.x in the build settings. It's necessary for the Tv simulator to show up

    0 讨论(0)
  • 2020-12-12 15:23

    The tvOS SDK is based off of iOS, but is not interchangeable. Unlike when the first iPad was released, the new Apple TV will not be capable of running iOS apps.

    The AppStore for the TV will only include apps built specifically for tvOS.

    For any iOS developers looking to create apps for Apple TV, I'd 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

    Specifically, check out the Inherited iOS Frameworks section to give you a sense of what will work out of the box from your existing iOS projects.

    0 讨论(0)
  • 2020-12-12 15:23

    In Xcode 7.1 (which introduces tvOS SDK) you can add a tvOS target as any other (File -> New -> Target... -> tvOS -> ...) and it supports both Objective-C and Swift, so yes - it's possible to share code between your iOS and tvOS app, you just need to check your source target membership and enable it on your tvOS target. To extend the purchases across iOS and tvOS app we should use Universal Purchases.

    0 讨论(0)
  • 2020-12-12 15:24

    Just to list out some limitations and challenges:
    1. There is no persistent local storage for apps on Apple TV. Data must be stored on iCloud.

    2. The maximum size of an Apple TV app is limited to 200MB. On-demand resources (app contents that are hosted on the App Store) should be used. Benefits are smaller app size and lazy loading of app resources.

    3. The UI is drastically different. Human Interface Guidelines must be followed as per the doc.

    4. Creating a Client-Server App using JavaScript and TVML framework.

    5. Controlling the UI touch focus. UIFocusEnvironment controls focus-related behavior for a branch of the view hierarchy. UIViewController conforms to UIFocusEnvironment protocol.

    6. Creating Parallax Artwork You have to create a LSR image with Xcode and then use terminal to create a LCR image. A UIImage object can display a LCR image correctly.

    0 讨论(0)
提交回复
热议问题